Skip to content

Commit

Permalink
Fix spike train loader
Browse files Browse the repository at this point in the history
  • Loading branch information
alejoe91 committed Mar 15, 2024
1 parent 3a0eab4 commit ebd4b02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/expipe_plugin_cinpla/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,21 +260,21 @@ def load_spiketrains(data_path, channel_group=None, lim=None):
unit_id for unit_index, unit_id in enumerate(sorting.unit_ids) if groups[unit_index] == channel_group
]
sptr = []
# build neo pbjects
for unit in unit_ids:
times = sorting.get_unit_spike_train(unit, return_times=True) * pq.s
# build neo objects
for unit in sorting.unit_ids:
spike_times = sorting.get_unit_spike_train(unit, return_times=True) * pq.s
if lim is None:
times = recording.get_times() * pq.s
t_start = times[0]
t_stop = times[-1]
else:
t_start = pq.Quantity(lim[0], "s")
t_stop = pq.Quantity(lim[1], "s")
mask = (times >= t_start) & (times <= t_stop)
times = times[mask]
mask = (spike_times >= t_start) & (spike_times <= t_stop)
spike_times = spike_times[mask]

st = neo.SpikeTrain(
times=times, t_start=t_start, t_stop=t_stop, sampling_rate=sorting.sampling_frequency * pq.Hz
times=spike_times, t_start=t_start, t_stop=t_stop, sampling_rate=sorting.sampling_frequency * pq.Hz
)
st.annotations.update({"name": unit})
for p in sorting.get_property_keys():
Expand Down
5 changes: 3 additions & 2 deletions src/expipe_plugin_cinpla/scripts/convert_old_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ def convert_old_project(
if exist_ok and not new_action_folder.is_dir():
# Copy action that previously failed
print(f">>> Re-copying action {action_id} to new project\n")
shutil.copytree(old_action_folder, new_action_folder,
ignore=shutil.ignore_patterns("main.exdir", ".git"))
shutil.copytree(
old_action_folder, new_action_folder, ignore=shutil.ignore_patterns("main.exdir", ".git")
)
new_action = new_project.actions[action_id]

# replace file in attributes.yaml
Expand Down

0 comments on commit ebd4b02

Please sign in to comment.