|
37 | 37 | SCIPY_ERR = None |
38 | 38 |
|
39 | 39 | from neo.io.baseio import BaseIO |
40 | | -from neo.core import (Block, Segment, AnalogSignal, Event, Epoch, SpikeTrain, |
41 | | - objectnames, class_by_name) |
| 40 | +from neo.core import (Block, Segment, AnalogSignal, IrregularlySampledSignal, |
| 41 | + Event, Epoch, SpikeTrain, objectnames, class_by_name) |
42 | 42 |
|
43 | 43 | classname_lower_to_upper = {} |
44 | 44 | for k in objectnames: |
@@ -190,7 +190,8 @@ class NeoMatlabIO(BaseIO): |
190 | 190 | is_readable = True |
191 | 191 | is_writable = True |
192 | 192 |
|
193 | | - supported_objects = [Block, Segment, AnalogSignal, Epoch, Event, SpikeTrain] |
| 193 | + supported_objects = [Block, Segment, AnalogSignal, IrregularlySampledSignal, |
| 194 | + Epoch, Event, SpikeTrain] |
194 | 195 | readable_objects = [Block] |
195 | 196 | writeable_objects = [Block] |
196 | 197 |
|
@@ -251,6 +252,10 @@ def write_block(self, bl, **kargs): |
251 | 252 | anasig_struct = self.create_struct_from_obj(anasig) |
252 | 253 | seg_struct['analogsignals'].append(anasig_struct) |
253 | 254 |
|
| 255 | + for irrsig in seg.irregularlysampledsignals: |
| 256 | + irrsig_struct = self.create_struct_from_obj(irrsig) |
| 257 | + seg_struct['irregularlysampledsignals'].append(irrsig_struct) |
| 258 | + |
254 | 259 | for ea in seg.events: |
255 | 260 | ea_struct = self.create_struct_from_obj(ea) |
256 | 261 | seg_struct['events'].append(ea_struct) |
@@ -348,7 +353,13 @@ def create_ob_from_struct(self, struct, classname): |
348 | 353 | else: |
349 | 354 | data_complement["t_start"] = 0.0 |
350 | 355 |
|
351 | | - ob = cl(arr, **data_complement) |
| 356 | + if "times" in (at[0] for at in cl._necessary_attrs) and quantity_attr != "times": |
| 357 | + # handle IrregularlySampledSignal |
| 358 | + times = getattr(struct, "times") |
| 359 | + data_complement["time_units"] = getattr(struct, "times_units") |
| 360 | + ob = cl(times, arr, **data_complement) |
| 361 | + else: |
| 362 | + ob = cl(arr, **data_complement) |
352 | 363 | else: |
353 | 364 | ob = cl() |
354 | 365 |
|
|
0 commit comments