Skip to content

Commit 139e99b

Browse files
committed
Update module import
1 parent 44be355 commit 139e99b

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

element_array_ephys/ephys.py

Lines changed: 22 additions & 22 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
@@ -142,8 +142,8 @@ class EphysFile(dj.Part):
142142

143143
def make(self, key):
144144

145-
session_dir = element_data_loader.utils.find_full_path(get_ephys_root_data_dir(),
146-
get_session_directory(key))
145+
session_dir = find_full_path(get_ephys_root_data_dir(),
146+
get_session_directory(key))
147147

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

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

193-
root_dir = element_data_loader.utils.find_root_directory(get_ephys_root_data_dir(), meta_filepath)
193+
root_dir = find_root_directory(get_ephys_root_data_dir(),
194+
meta_filepath)
194195
self.EphysFile.insert1({
195196
**key,
196197
'file_path': meta_filepath.relative_to(root_dir).as_posix()})
@@ -223,8 +224,7 @@ def make(self, key):
223224
'acq_software': acq_software,
224225
'sampling_rate': probe_data.ap_meta['sample_rate']})
225226

226-
root_dir = element_data_loader.utils.find_root_directory(
227-
get_ephys_root_data_dir(),
227+
root_dir = find_root_directory(get_ephys_root_data_dir(),
228228
probe_data.recording_info['recording_files'][0])
229229
self.EphysFile.insert([{**key,
230230
'file_path': fp.relative_to(root_dir).as_posix()}
@@ -294,9 +294,8 @@ def make(self, key):
294294
electrode_keys.append(probe_electrodes[(shank, shank_col, shank_row)])
295295
elif acq_software == 'Open Ephys':
296296

297-
session_dir = element_data_loader.utils.find_full_path(
298-
get_ephys_root_data_dir(),
299-
get_session_directory(key))
297+
session_dir = find_full_path(get_ephys_root_data_dir(),
298+
get_session_directory(key))
300299

301300
loaded_oe = openephys.OpenEphys(session_dir)
302301
oe_probe = loaded_oe.probes[probe_sn]
@@ -365,7 +364,7 @@ def insert_new_params(cls, processing_method: str, paramset_idx: int,
365364
'paramset_idx': paramset_idx,
366365
'paramset_desc': paramset_desc,
367366
'params': params,
368-
'param_set_hash': element_data_loader.utils.dict_to_uuid(params)}
367+
'param_set_hash': dict_to_uuid(params)}
369368
param_query = cls & {'param_set_hash': param_dict['param_set_hash']}
370369

371370
if param_query: # If the specified param-set already exists
@@ -427,7 +426,7 @@ class Clustering(dj.Imported):
427426
def make(self, key):
428427
task_mode, output_dir = (ClusteringTask & key).fetch1(
429428
'task_mode', 'clustering_output_dir')
430-
kilosort_dir = element_data_loader.utils.find_full_path(get_ephys_root_data_dir(), output_dir)
429+
kilosort_dir = find_full_path(get_ephys_root_data_dir(), output_dir)
431430

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

468467
task_mode, output_dir = (ClusteringTask & key).fetch1(
469468
'task_mode', 'clustering_output_dir')
470-
kilosort_dir = element_data_loader.utils.find_full_path(get_ephys_root_data_dir(), output_dir)
469+
kilosort_dir = find_full_path(get_ephys_root_data_dir(), output_dir)
471470

472471
creation_time, is_curated, is_qc = kilosort.extract_clustering_info(kilosort_dir)
473472
# Synthesize curation_id
@@ -503,7 +502,7 @@ class Unit(dj.Part):
503502

504503
def make(self, key):
505504
output_dir = (Curation & key).fetch1('curation_output_dir')
506-
kilosort_dir = element_data_loader.utils.find_full_path(get_ephys_root_data_dir(), output_dir)
505+
kilosort_dir = find_full_path(get_ephys_root_data_dir(), output_dir)
507506

508507
kilosort_dataset = kilosort.Kilosort(kilosort_dir)
509508
acq_software = (EphysRecording & key).fetch1('acq_software')
@@ -581,7 +580,7 @@ class Waveform(dj.Part):
581580

582581
def make(self, key):
583582
output_dir = (Curation & key).fetch1('curation_output_dir')
584-
kilosort_dir = element_data_loader.utils.find_full_path(get_ephys_root_data_dir(), output_dir)
583+
kilosort_dir = find_full_path(get_ephys_root_data_dir(), output_dir)
585584

586585
kilosort_dataset = kilosort.Kilosort(kilosort_dir)
587586

@@ -623,8 +622,8 @@ def yield_unit_waveforms():
623622
spikeglx_meta_filepath = get_spikeglx_meta_filepath(key)
624623
neuropixels_recording = spikeglx.SpikeGLX(spikeglx_meta_filepath.parent)
625624
elif acq_software == 'Open Ephys':
626-
session_dir = element_data_loader.utils.find_full_path(get_ephys_root_data_dir(),
627-
get_session_directory(key))
625+
session_dir = find_full_path(get_ephys_root_data_dir(),
626+
get_session_directory(key))
628627
openephys_dataset = openephys.OpenEphys(session_dir)
629628
neuropixels_recording = openephys_dataset.probes[probe_serial_number]
630629

@@ -665,13 +664,14 @@ def get_spikeglx_meta_filepath(ephys_recording_key):
665664
& 'file_path LIKE "%.ap.meta"').fetch1('file_path')
666665

667666
try:
668-
spikeglx_meta_filepath = element_data_loader.utils.find_full_path(get_ephys_root_data_dir(),
667+
spikeglx_meta_filepath = find_full_path(get_ephys_root_data_dir(),
669668
spikeglx_meta_filepath)
670669
except FileNotFoundError:
671670
# if not found, search in session_dir again
672671
if not spikeglx_meta_filepath.exists():
673-
session_dir = element_data_loader.utils.find_full_path(get_ephys_root_data_dir(),
674-
get_session_directory(ephys_recording_key))
672+
session_dir = find_full_path(get_ephys_root_data_dir(),
673+
get_session_directory(
674+
ephys_recording_key))
675675
inserted_probe_serial_number = (ProbeInsertion * probe.Probe
676676
& ephys_recording_key).fetch1('probe')
677677

@@ -708,8 +708,8 @@ def get_neuropixels_channel2electrode_map(ephys_recording_key, acq_software):
708708
for recorded_site, (shank, shank_col, shank_row, _) in enumerate(
709709
spikeglx_meta.shankmap['data'])}
710710
elif acq_software == 'Open Ephys':
711-
session_dir = element_data_loader.utils.find_full_path(get_ephys_root_data_dir(),
712-
get_session_directory(ephys_recording_key))
711+
session_dir = find_full_path(get_ephys_root_data_dir(),
712+
get_session_directory(ephys_recording_key))
713713
openephys_dataset = openephys.OpenEphys(session_dir)
714714
probe_serial_number = (ProbeInsertion & ephys_recording_key).fetch1('probe')
715715
probe_dataset = openephys_dataset.probes[probe_serial_number]
@@ -736,7 +736,7 @@ def generate_electrode_config(probe_type: str, electrodes: list):
736736
:return: a dict representing a key of the probe.ElectrodeConfig table
737737
"""
738738
# compute hash for the electrode config (hash of dict of all ElectrodeConfig.Electrode)
739-
electrode_config_hash = element_data_loader.utils.dict_to_uuid({k['electrode']: k for k in electrodes})
739+
electrode_config_hash = dict_to_uuid({k['electrode']: k for k in electrodes})
740740

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

0 commit comments

Comments
 (0)