@schemaclassLFPElectrodeGroup(SpyglassMixin,dj.Manual):definition=""" -> Session # the session to which this LFP belongs lfp_electrode_group_name: varchar(200) # the name of this group of electrodes """classLFPElectrode(SpyglassMixin,dj.Part):definition=""" -> LFPElectrodeGroup # the group of electrodes to be filtered -> Electrode # the electrode to be filtered """@staticmethoddefcreate_lfp_electrode_group(nwb_file_name:str,group_name:str,electrode_list:list[int]):"""Adds an LFPElectrodeGroup and the individual electrodes Parameters ---------- nwb_file_name : str The name of the nwb file (e.g. the session) group_name : str The name of this group (< 200 char) electrode_list : list A list of the electrode ids to include in this group. """# remove the session and then recreate the session and Electrode list# check to see if the user allowed the deletionkey={"nwb_file_name":nwb_file_name,"lfp_electrode_group_name":group_name,}LFPElectrodeGroup().insert1(key,skip_duplicates=True)# TODO: do this in a better wayall_electrodes=(Electrode()&{"nwb_file_name":nwb_file_name}).fetch(as_dict=True)primary_key=Electrode.primary_keyifisinstance(electrode_list,ndarray):# convert to list if it is an numpy arrayelectrode_list=list(electrode_list.astype(int).reshape(-1))foreinall_electrodes:# create a dictionary so we can insert the electrodesife["electrode_id"]inelectrode_list:lfpelectdict={k:vfork,vine.items()ifkinprimary_key}lfpelectdict["lfp_electrode_group_name"]=group_nameLFPElectrodeGroup().LFPElectrode.insert1(lfpelectdict,skip_duplicates=True)
@staticmethoddefcreate_lfp_electrode_group(nwb_file_name:str,group_name:str,electrode_list:list[int]):"""Adds an LFPElectrodeGroup and the individual electrodes Parameters ---------- nwb_file_name : str The name of the nwb file (e.g. the session) group_name : str The name of this group (< 200 char) electrode_list : list A list of the electrode ids to include in this group. """# remove the session and then recreate the session and Electrode list# check to see if the user allowed the deletionkey={"nwb_file_name":nwb_file_name,"lfp_electrode_group_name":group_name,}LFPElectrodeGroup().insert1(key,skip_duplicates=True)# TODO: do this in a better wayall_electrodes=(Electrode()&{"nwb_file_name":nwb_file_name}).fetch(as_dict=True)primary_key=Electrode.primary_keyifisinstance(electrode_list,ndarray):# convert to list if it is an numpy arrayelectrode_list=list(electrode_list.astype(int).reshape(-1))foreinall_electrodes:# create a dictionary so we can insert the electrodesife["electrode_id"]inelectrode_list:lfpelectdict={k:vfork,vine.items()ifkinprimary_key}lfpelectdict["lfp_electrode_group_name"]=group_nameLFPElectrodeGroup().LFPElectrode.insert1(lfpelectdict,skip_duplicates=True)