Skip to content

Commit 185cd6b

Browse files
nwb_image_series
1 parent 2a751aa commit 185cd6b

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

src/pynwb/tests/test_read_nwb.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import os
2-
from unittest.mock import Mock
2+
from datetime import datetime
33

44
import pynwb
5-
from pynwb import NWBHDF5IO, ProcessingModule
6-
7-
from datetime import datetime
85
from dateutil.tz import tzlocal
96
from pynwb import NWBFile
10-
from pynwb.behavior import BehavioralTimeSeries
7+
from pynwb import NWBHDF5IO, ProcessingModule
8+
from pynwb.behavior import BehavioralEvents
119
from pynwb.device import Device
1210
from pynwb.testing import TestCase
1311

@@ -139,34 +137,41 @@ def test_read_nwb_camera_device_successfully(self):
139137
self.delete_nwb('camera_device')
140138

141139
def test_read_nwb_nwb_image_series_successfully(self):
142-
mock_device_1 = Mock(spec=Device)
143-
mock_device_2 = Mock(spec=Device)
140+
device_1 = Device('device1')
141+
device_2 = Device('device2')
144142
mock_timestamps = [1, 2, 3]
145-
mock_external_file = []
143+
mock_external_file = ['some file']
146144

147145
nwb_image_series = NwbImageSeries(
148146
name='NwbImageSeries1',
149147
timestamps=mock_timestamps,
150148
external_file=mock_external_file,
151-
devices=[mock_device_1, mock_device_2]
149+
devices=[device_1, device_2]
152150
)
153-
behavioral_time_series = BehavioralTimeSeries(name="ImageSeries")
151+
152+
behavioral_time_series = BehavioralEvents(name="BehavioralTimeSeries")
154153
behavioral_time_series.add_timeseries(nwb_image_series)
155-
processing_module = ProcessingModule(name='PM_ImageSeries', description='')
154+
processing_module = ProcessingModule(name='ProcessingModule', description='')
155+
processing_module.add_data_interface(behavioral_time_series)
156156
self.nwb_file_content.add_processing_module(processing_module)
157-
self.nwb_file_content.processing['PM_ImageSeries'].add(behavioral_time_series)
157+
158+
self.nwb_file_content.add_stimulus_template(nwb_image_series)
158159

159160
nwb_file_handler = NWBHDF5IO('nwb_image_series.nwb', mode='w')
160161
nwb_file_handler.write(self.nwb_file_content)
161-
# nwb_file_handler.close()
162-
#
163-
# self.assertTrue(os.path.exists('nwb_image_series.nwb'))
164-
# with pynwb.NWBHDF5IO('nwb_image_series.nwb', 'r', load_namespaces=True) as nwb_file_handler:
165-
# nwb_file = nwb_file_handler.read()
166-
# print(nwb_file.processing['PM_ImageSeries'])
167-
# self.assertContainerEqual(nwb_file.processing['PM_ImageSeries'], nwb_image_series)
168-
#
169-
# self.delete_nwb('nwb_image_series')
162+
nwb_file_handler.close()
163+
164+
self.assertTrue(os.path.exists('nwb_image_series.nwb'))
165+
with pynwb.NWBHDF5IO('nwb_image_series.nwb', 'r', load_namespaces=True) as nwb_file_handler:
166+
nwb_file = nwb_file_handler.read()
167+
self.assertContainerEqual(nwb_file.stimulus_template['NwbImageSeries1'], nwb_image_series)
168+
self.assertContainerEqual(
169+
nwb_file.processing['ProcessingModule'].data_interfaces['BehavioralTimeSeries'].
170+
time_series['NwbImageSeries1'],
171+
nwb_image_series
172+
)
173+
174+
self.delete_nwb('nwb_image_series')
170175

171176
def test_read_nwb_nwb_electrode_group_successfully(self):
172177
device = Device('device_0')

0 commit comments

Comments
 (0)