Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions bluepyefe/nwbreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def read(self):


class ScalaNWBReader(NWBReader):

def read(self):
""" Read and format the content of the NWB file

Expand All @@ -112,6 +113,11 @@ def read(self):

data = []

if self.repetition:
repetitions_content = self.content['general']['intracellular_ephys']['intracellular_recordings']['repetition']
if isinstance(self.repetition, (int, str)):
self.repetition = [int(self.repetition)]

for sweep in list(self.content['acquisition'].keys()):
key_current = sweep.replace('Series', 'StimulusSeries')
try:
Expand All @@ -132,12 +138,23 @@ def read(self):
if key_current not in self.content['stimulus']['presentation']:
continue

data.append(self._format_nwb_trace(
voltage=self.content['acquisition'][sweep]['data'],
current=self.content['stimulus']['presentation'][key_current]['data'],
start_time=self.content["acquisition"][sweep]["starting_time"],
trace_name=sweep,
))
if self.repetition:
sweep_id = int(sweep.split("_")[-1])
if (int(repetitions_content[sweep_id]) in self.repetition):
data.append(self._format_nwb_trace(
voltage=self.content['acquisition'][sweep]['data'],
current=self.content['stimulus']['presentation'][key_current]['data'],
start_time=self.content['acquisition'][sweep]["starting_time"],
trace_name=sweep,
repetition=int(repetitions_content[sweep_id])
))
else:
data.append(self._format_nwb_trace(
voltage=self.content['acquisition'][sweep]['data'],
current=self.content['stimulus']['presentation'][key_current]['data'],
start_time=self.content["acquisition"][sweep]["starting_time"],
trace_name=sweep,
))

return data

Expand Down
10 changes: 5 additions & 5 deletions bluepyefe/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,15 @@ def nwb_reader(in_data):
with h5py.File(in_data["filepath"], "r") as content:
if "data_organization" in content:
reader = BBPNWBReader(
content,
target_protocols,
in_data.get("repetition", None),
in_data.get("v_file", None)
content=content,
target_protocols=target_protocols,
v_file=in_data.get("v_file", None),
repetition=in_data.get("repetition", None),
)
elif "timeseries" in content["acquisition"].keys():
reader = AIBSNWBReader(content, target_protocols)
else:
reader = ScalaNWBReader(content, target_protocols)
reader = ScalaNWBReader(content, target_protocols, repetition=in_data.get("repetition", None))

data = reader.read()

Expand Down