简体   繁体   English

无法重新填充 ElectrodeGroup 数据联合表

[英]Cannot repopulate ElectrodeGroup datajoint table

I'm a researcher in Loren Frank's lab at UCSF using datajoint and files in the nwb format.我是加州大学旧金山分校 Loren Frank 实验室的一名研究员,使用数据联合和 nwb 格式的文件。 I made some changes to our code for defining entries in our ElectrodeGroup table, and was hoping to test those by deleting an entry in the table and regenerating it with the new code.我对定义 ElectrodeGroup 表中条目的代码进行了一些更改,并希望通过删除表中的条目并使用新代码重新生成它来测试这些。 I was able to delete the entry, but cannot repopulate it.我能够删除该条目,但无法重新填充它。 In particular, when I run ElectrodeGroup.populate() or ElectrodeGroup.populate({"nwb_file_name": my_file_name}), no changes are made to the table.特别是,当我运行 ElectrodeGroup.populate() 或 ElectrodeGroup.populate({"nwb_file_name": my_file_name}) 时,不会对表进行任何更改。 I confirmed that the electrode group I deleted and am trying to regenerate is defined in the original nwb file.我确认我删除并尝试重新生成的电极组是在原始 nwb 文件中定义的。 I am seeking input on why the populate command seems to not be working here.我正在寻求有关为什么 populate 命令似乎在这里不起作用的输入。 Thanks in advance for any help!提前感谢您的帮助!

This user also contacted our team through another channel.该用户还通过其他渠道联系了我们的团队。 Sharing the solution below for future users, in reference to this schema .参考此架构,为未来的用户分享以下解决方案 In short, the populate process is reserved for unique upstream primary keys.简而言之,填充过程是为唯一的上游主键保留的。

Since the ElectrodeGroup's only upstream table dependency is Session, the make method will only be called if there are no electrode groups for that session.由于 ElectrodeGroup 的唯一上游表依赖项是 Session,因此只有在该会话没有电极组时才会调用 make 方法。 This is because from the perspective of DataJoint, the only 'guaranteed' knowledge about what should exist for this table is defined solely by the presence/absence of related upstream records.这是因为从 DataJoint 的角度来看,关于该表应该存在什么的唯一“保证”知识仅由相关上游记录的存在/不存在定义。 Since the 'new' primary 'electrode_group_name' attribute is defined by the ElectrodeGroup table itself, DataJoint doesn't know how many copies will be created by make, and so simply invokes make 1 time per Session, expecting the single make invocation to fully define all possible electrode_group_name values the table will use.由于 'new' 主要的 'electrode_group_name' 属性是由 ElectrodeGroup 表本身定义的,DataJoint 不知道 make 将创建多少个副本,因此每个 Session 只需调用 make 1 次,期望单个 make 调用完全定义表将使用的所有可能的电极组名称值。 If there is one value for that session, no work needs to be done, so no make() invocation occurs.如果该会话有一个值,则不需要进行任何工作,因此不会发生 make() 调用。

There are a couple possible solutions:有几个可能的解决方案:

  1. Model the electrode group explicitly, with a table defines the existence of an electrode group (eg, ElectrodeGroupConfiguration).显式地对电极组进行建模,使用表格定义电极组的存在(例如,ElectrodeGroupConfiguration)。 This ElectrodeGroup would then inherit primary keys from both Session and ElectrodeGroupConfiguration.然后,此 ElectrodeGroup 将从 Session 和 ElectrodeGroupConfiguration 继承主键。 The ElectrodeGroup make function would be adjusted to load that unique keys across upstream tables.将调整 ElectrodeGroup 的 make 函数以跨上游表加载该唯一键。
  2. Adjust the make function to handle the partial insert/update case, and call the make function directly with the desired primary key when these kinds of 'abnormal' updates need to occur.调整 make 函数以处理部分插入/更新情况,并在需要发生这些“异常”更新时直接使用所需的主键调用 make 函数。

Method #1 is 'cleanest' w/r/t to the DataJoint data model (explicitly modeled data dependencies using make/populate), whereas #2 is slightly 'escaping' the DataJoint data model in a controlled way to achieve a desired schema/data result.方法 #1 对 DataJoint 数据模型是“最干净的”(使用 make/populate 显式建模数据依赖关系),而方法 #2 以受控方式稍微“转义”DataJoint 数据模型以实现所需的模式/数据结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM