Skip to content

Commit e225d6b

Browse files
add additional meta data to channel directly
1 parent 27a86e0 commit e225d6b

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

ephys/classes/channels.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def __init__(self, sweep_count: int, sweep_length: int, unit: str):
7070
self.sampling_rate: Quantity = Quantity(0, "Hz")
7171
self.starting_time: Quantity = Quantity(np.zeros(self.sweep_count), "s")
7272
self.rec_datetime: datetime.datetime | None = None
73+
self.group: int | None = None
74+
self.recording_type: str | None = None
7375
self.check_clamp()
7476

7577
def insert_data(self, data: np.ndarray, sweep_count: int) -> None:
@@ -135,6 +137,34 @@ def channel_average(self, sweep_subset: Any = None) -> None:
135137
sweep_subset = _get_sweep_subset(self.data, sweep_subset)
136138
self.average = ChannelAverage(self, sweep_subset)
137139

140+
def add_group(self, group: int) -> None:
141+
"""
142+
Assigns a group number to the channel.
143+
144+
Parameters:
145+
group (int): The group number to be assigned to the channel.
146+
147+
Returns:
148+
None
149+
"""
150+
self.group = group
151+
152+
def add_recording_type(self, recording_type: str) -> None:
153+
"""
154+
Assigns a recording type to the channel.
155+
156+
Parameters:
157+
recording_type (str): The recording type to be assigned to the channel.
158+
159+
Returns:
160+
None
161+
"""
162+
if recording_type not in ["field", "cell"]:
163+
print(
164+
"Warning: Unknown recording type. Please use 'field' or 'cell'. Invalid type might cause issues later on."
165+
)
166+
self.recording_type = recording_type
167+
138168

139169
class ChannelInformation:
140170
"""

ephys/classes/class_functions.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ def wcp_trace(trace, file_path: str, quick_check: bool = True) -> None:
6363
trace_insert.sampling_rate = trace.sampling_rate
6464
else:
6565
raise ValueError("Signal type not recognized")
66+
67+
trace_insert.add_group(
68+
trace.channel_information.channel_grouping[channel_index]
69+
)
70+
trace_insert.add_recording_type(
71+
trace.channel_information.recording_type[channel_index]
72+
)
73+
6674
for segment_index, segment in enumerate(data_block.segments):
6775
# handle channel mismatch (channels are loaded into the first channel with same label)
6876
# TODO: check if it can be fixed on neo side or if it is only specific file scenarios
@@ -139,6 +147,14 @@ def abf_trace(trace, file_path: str, quick_check: bool = True) -> None:
139147
trace_insert.sampling_rate = trace.sampling_rate
140148
else:
141149
raise ValueError("Signal type not recognized")
150+
151+
trace_insert.add_group(
152+
trace.channel_information.channel_grouping[channel_index]
153+
)
154+
trace_insert.add_recording_type(
155+
trace.channel_information.recording_type[channel_index]
156+
)
157+
142158
for segment_index, segment in enumerate(data_block.segments):
143159
trace_insert.insert_data(
144160
segment.analogsignals[channel_index], segment_index

0 commit comments

Comments
 (0)