Skip to content

Commit 818cc53

Browse files
committed
Update module import
1 parent 9881350 commit 818cc53

File tree

1 file changed

+24
-33
lines changed

1 file changed

+24
-33
lines changed

element_array_ephys/ephys_chronic.py

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import numpy as np
55
import inspect
66
import importlib
7-
import element_data_loader.utils
7+
from element_data_loader.utils import find_root_directory, find_full_path, dict_to_uuid
88

99
from .readers import spikeglx, kilosort, openephys
1010
from . import probe
@@ -143,8 +143,8 @@ class EphysFile(dj.Part):
143143
"""
144144

145145
def make(self, key):
146-
session_dir = element_data_loader.utils.find_full_path(get_ephys_root_data_dir(),
147-
get_session_directory(key))
146+
session_dir = find_full_path(get_ephys_root_data_dir(),
147+
get_session_directory(key))
148148

149149
inserted_probe_serial_number = (ProbeInsertion * probe.Probe & key).fetch1('probe')
150150

@@ -191,9 +191,8 @@ def make(self, key):
191191
'acq_software': acq_software,
192192
'sampling_rate': spikeglx_meta.meta['imSampRate']})
193193

194-
root_dir = element_data_loader.utils.find_root_directory(
195-
get_ephys_root_data_dir(),
196-
meta_filepath)
194+
root_dir = find_root_directory(get_ephys_root_data_dir(),
195+
meta_filepath)
197196
self.EphysFile.insert1({
198197
**key,
199198
'file_path': meta_filepath.relative_to(root_dir).as_posix()})
@@ -226,9 +225,8 @@ def make(self, key):
226225
'acq_software': acq_software,
227226
'sampling_rate': probe_data.ap_meta['sample_rate']})
228227

229-
root_dir = element_data_loader.utils.find_root_directory(
230-
get_ephys_root_data_dir(),
231-
probe_data.recording_info['recording_files'][0])
228+
root_dir = find_root_directory(get_ephys_root_data_dir(),
229+
probe_data.recording_info['recording_files'][0])
232230
self.EphysFile.insert([{**key,
233231
'file_path': fp.relative_to(root_dir).as_posix()}
234232
for fp in probe_data.recording_info['recording_files']])
@@ -296,9 +294,8 @@ def make(self, key):
296294
shank, shank_col, shank_row, _ = spikeglx_recording.apmeta.shankmap['data'][recorded_site]
297295
electrode_keys.append(probe_electrodes[(shank, shank_col, shank_row)])
298296
elif acq_software == 'Open Ephys':
299-
session_dir = element_data_loader.utils.find_full_path(
300-
get_ephys_root_data_dir(),
301-
get_session_directory(key))
297+
session_dir = find_full_path(get_ephys_root_data_dir(),
298+
get_session_directory(key))
302299
loaded_oe = openephys.OpenEphys(session_dir)
303300
oe_probe = loaded_oe.probes[probe_sn]
304301

@@ -366,7 +363,7 @@ def insert_new_params(cls, processing_method: str, paramset_idx: int,
366363
'paramset_idx': paramset_idx,
367364
'paramset_desc': paramset_desc,
368365
'params': params,
369-
'param_set_hash': element_data_loader.utils.dict_to_uuid(params)}
366+
'param_set_hash': dict_to_uuid(params)}
370367
param_query = cls & {'param_set_hash': param_dict['param_set_hash']}
371368

372369
if param_query: # If the specified param-set already exists
@@ -428,7 +425,7 @@ class Clustering(dj.Imported):
428425
def make(self, key):
429426
task_mode, output_dir = (ClusteringTask & key).fetch1(
430427
'task_mode', 'clustering_output_dir')
431-
kilosort_dir = element_data_loader.utils.find_full_path(get_ephys_root_data_dir(), output_dir)
428+
kilosort_dir = find_full_path(get_ephys_root_data_dir(), output_dir)
432429

433430
if task_mode == 'load':
434431
kilosort_dataset = kilosort.Kilosort(kilosort_dir) # check if the directory is a valid Kilosort output
@@ -467,7 +464,7 @@ def create1_from_clustering_task(self, key, curation_note=''):
467464

468465
task_mode, output_dir = (ClusteringTask & key).fetch1(
469466
'task_mode', 'clustering_output_dir')
470-
kilosort_dir = element_data_loader.utils.find_full_path(get_ephys_root_data_dir(), output_dir)
467+
kilosort_dir = find_full_path(get_ephys_root_data_dir(), output_dir)
471468

472469
creation_time, is_curated, is_qc = kilosort.extract_clustering_info(kilosort_dir)
473470
# Synthesize curation_id
@@ -501,7 +498,7 @@ class Unit(dj.Part):
501498

502499
def make(self, key):
503500
output_dir = (Curation & key).fetch1('curation_output_dir')
504-
kilosort_dir = element_data_loader.utils.find_full_path(get_ephys_root_data_dir(), output_dir)
501+
kilosort_dir = find_full_path(get_ephys_root_data_dir(), output_dir)
505502

506503
kilosort_dataset = kilosort.Kilosort(kilosort_dir)
507504
acq_software = (EphysRecording & key).fetch1('acq_software')
@@ -579,9 +576,7 @@ class Waveform(dj.Part):
579576

580577
def make(self, key):
581578
output_dir = (Curation & key).fetch1('curation_output_dir')
582-
kilosort_dir = element_data_loader.utils.find_full_path(
583-
get_ephys_root_data_dir(),
584-
output_dir)
579+
kilosort_dir = find_full_path(get_ephys_root_data_dir(), output_dir)
585580

586581
kilosort_dataset = kilosort.Kilosort(kilosort_dir)
587582

@@ -623,9 +618,8 @@ def yield_unit_waveforms():
623618
spikeglx_meta_filepath = get_spikeglx_meta_filepath(key)
624619
neuropixels_recording = spikeglx.SpikeGLX(spikeglx_meta_filepath.parent)
625620
elif acq_software == 'Open Ephys':
626-
session_dir = element_data_loader.utils.find_full_path(
627-
get_ephys_root_data_dir(),
628-
get_session_directory(key))
621+
session_dir = find_full_path(get_ephys_root_data_dir(),
622+
get_session_directory(key))
629623
openephys_dataset = openephys.OpenEphys(session_dir)
630624
neuropixels_recording = openephys_dataset.probes[probe_serial_number]
631625

@@ -666,15 +660,14 @@ def get_spikeglx_meta_filepath(ephys_recording_key):
666660
& 'file_path LIKE "%.ap.meta"').fetch1('file_path')
667661

668662
try:
669-
spikeglx_meta_filepath = element_data_loader.utils.find_full_path(
670-
get_ephys_root_data_dir(),
671-
spikeglx_meta_filepath)
663+
spikeglx_meta_filepath = find_full_path(get_ephys_root_data_dir(),
664+
spikeglx_meta_filepath)
672665
except FileNotFoundError:
673666
# if not found, search in session_dir again
674667
if not spikeglx_meta_filepath.exists():
675-
session_dir = element_data_loader.utils.find_full_path(
676-
get_ephys_root_data_dir(),
677-
get_session_directory(ephys_recording_key))
668+
session_dir = find_full_path(get_ephys_root_data_dir(),
669+
get_session_directory(
670+
ephys_recording_key))
678671
inserted_probe_serial_number = (ProbeInsertion * probe.Probe
679672
& ephys_recording_key).fetch1('probe')
680673

@@ -712,9 +705,8 @@ def get_neuropixels_channel2electrode_map(ephys_recording_key, acq_software):
712705
for recorded_site, (shank, shank_col, shank_row, _) in enumerate(
713706
spikeglx_meta.shankmap['data'])}
714707
elif acq_software == 'Open Ephys':
715-
session_dir = element_data_loader.utils.find_full_path(
716-
get_ephys_root_data_dir(),
717-
get_session_directory(ephys_recording_key))
708+
session_dir = find_full_path(get_ephys_root_data_dir(),
709+
get_session_directory(ephys_recording_key))
718710
openephys_dataset = openephys.OpenEphys(session_dir)
719711
probe_serial_number = (ProbeInsertion & ephys_recording_key).fetch1('probe')
720712
probe_dataset = openephys_dataset.probes[probe_serial_number]
@@ -741,8 +733,7 @@ def generate_electrode_config(probe_type: str, electrodes: list):
741733
:return: a dict representing a key of the probe.ElectrodeConfig table
742734
"""
743735
# compute hash for the electrode config (hash of dict of all ElectrodeConfig.Electrode)
744-
electrode_config_hash = element_data_loader.utils.dict_to_uuid(
745-
{k['electrode']: k for k in electrodes})
736+
electrode_config_hash = dict_to_uuid({k['electrode']: k for k in electrodes})
746737

747738
electrode_list = sorted([k['electrode'] for k in electrodes])
748739
electrode_gaps = ([-1]

0 commit comments

Comments
 (0)