Skip to content

Commit d919e65

Browse files
committed
add group and imagesequence
1 parent 3781bff commit d919e65

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

neo/io/neomatlabio.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@
2222

2323

2424
from neo.io.baseio import BaseIO
25-
from neo.core import (Block, Segment, AnalogSignal, IrregularlySampledSignal,
26-
Event, Epoch, SpikeTrain, objectnames, class_by_name)
25+
from neo.core import (Block, Segment, AnalogSignal,
26+
IrregularlySampledSignal, Event,
27+
Epoch, SpikeTrain,
28+
Group, ImageSequence,
29+
objectnames, class_by_name)
2730

2831
classname_lower_to_upper = {}
2932
for k in objectnames:
@@ -176,7 +179,7 @@ class NeoMatlabIO(BaseIO):
176179
is_writable = True
177180

178181
supported_objects = [Block, Segment, AnalogSignal, IrregularlySampledSignal,
179-
Epoch, Event, SpikeTrain]
182+
Epoch, Event, SpikeTrain, Group, ImageSequence]
180183
readable_objects = [Block]
181184
writeable_objects = [Block]
182185

@@ -213,7 +216,7 @@ def read_block(self, lazy=False):
213216
214217
"""
215218
import scipy.io
216-
assert not lazy, 'Do not support lazy'
219+
assert not lazy, 'Does not support lazy'
217220

218221
d = scipy.io.loadmat(self.filename, struct_as_record=False,
219222
squeeze_me=True, mat_dtype=True)
@@ -259,6 +262,14 @@ def write_block(self, bl, **kargs):
259262
sptr_struct = self.create_struct_from_obj(sptr)
260263
seg_struct['spiketrains'].append(sptr_struct)
261264

265+
for image_sq in seg.imagesequences:
266+
image_sq_structure = self.create_struct_from_obj(image_sq)
267+
seg_struct['imagesequences'].append(image_sq_structure)
268+
269+
for group in bl.groups:
270+
group_structure = self.create_struct_from_obj(group)
271+
bl_struct['groups'].append(group_structure)
272+
262273
scipy.io.savemat(self.filename, {'block': bl_struct}, oned_as='row')
263274

264275
def create_struct_from_obj(self, ob):
@@ -343,6 +354,11 @@ def create_ob_from_struct(self, struct, classname):
343354
data_complement["t_start"] = arr.min()
344355
else:
345356
data_complement["t_start"] = 0.0
357+
if "spatial_scale" in (at[0] for at in cl._necessary_attrs):
358+
if len(arr) > 0:
359+
data_complement["spatial_scale"] = arr
360+
else:
361+
pass #
346362

347363
if "times" in (at[0] for at in cl._necessary_attrs) and quantity_attr != "times":
348364
# handle IrregularlySampledSignal

0 commit comments

Comments
 (0)