示例#1
0
 def test_intersecting_links(self):
     gb1 = GroupBuilder(
         'gb1',
         links={'link2': LinkBuilder(GroupBuilder('target1'), 'link2')})
     gb2 = GroupBuilder(
         'gb2',
         links={'link2': LinkBuilder(GroupBuilder('target2'), 'link2')})
     gb1.deep_update(gb2)
     self.assertIn('link2', gb2)
     self.assertEqual(gb1['link2'], gb2['link2'])
示例#2
0
 def test_mutually_exclusive_links(self):
     gb1 = GroupBuilder(
         'gb1',
         links={'link1': LinkBuilder(GroupBuilder('target1'), 'link1')})
     gb2 = GroupBuilder(
         'gb2',
         links={'link2': LinkBuilder(GroupBuilder('target2'), 'link2')})
     gb1.deep_update(gb2)
     self.assertIn('link2', gb2)
     self.assertEqual(gb1['link2'], gb2['link2'])
示例#3
0
 def setUpBuilder(self):
     device = GroupBuilder('device_name',
                           attributes={
                               'help': 'A recording device e.g. amplifier',
                               'namespace': 'core',
                               'neurodata_type': 'Device'
                           })
     datasets = [
         DatasetBuilder('slice', data=u'tissue slice'),
         DatasetBuilder('resistance', data=u'something measured in ohms'),
         DatasetBuilder('seal', data=u'sealing method'),
         DatasetBuilder('description', data=u'a fake electrode object'),
         DatasetBuilder('location', data=u'Springfield Elementary School'),
         DatasetBuilder('filtering',
                        data=u'a meaningless free-form text field'),
         DatasetBuilder('initial_access_resistance',
                        data=u'I guess this changes'),
     ]
     elec = GroupBuilder('elec0',
                         attributes={
                             'help':
                             'Metadata about an intracellular electrode',
                             'namespace': 'core',
                             'neurodata_type': 'IntracellularElectrode',
                         },
                         datasets={d.name: d
                                   for d in datasets},
                         links={'device': LinkBuilder(device, 'device')})
     return elec
示例#4
0
 def setUpBuilder(self):
     optchan_builder = GroupBuilder(
         'optchan1',
         attributes={
             'neurodata_type': 'OpticalChannel',
             'namespace': 'core',
             'help': 'Metadata about an optical channel used to record from an imaging plane'},
         datasets={
             'description': DatasetBuilder('description', 'a fake OpticalChannel'),
             'emission_lambda': DatasetBuilder('emission_lambda', 500.)},
     )
     device_builder = GroupBuilder('dev1',
                                   attributes={'neurodata_type': 'Device',
                                               'namespace': 'core',
                                               'help': 'A recording device e.g. amplifier'})
     return GroupBuilder(
         'imgpln1',
         attributes={
             'neurodata_type': 'ImagingPlane',
             'namespace': 'core',
             'help': 'Metadata about an imaging plane'},
         datasets={
             'description': DatasetBuilder('description', 'a fake ImagingPlane'),
             'excitation_lambda': DatasetBuilder('excitation_lambda', 600.),
             'imaging_rate': DatasetBuilder('imaging_rate', 300.),
             'indicator': DatasetBuilder('indicator', 'GFP'),
             'location': DatasetBuilder('location', 'somewhere in the brain')},
         groups={
             'optchan1': optchan_builder
         },
         links={
             'device': LinkBuilder(device_builder, 'device')
         }
     )
示例#5
0
    def setUp(self):
        self.subgroup1 = GroupBuilder('subgroup1')
        self.dataset1 = DatasetBuilder('dataset1', list(range(10)))
        self.soft_link1 = LinkBuilder(self.subgroup1, 'soft_link1')
        self.int_attr = 1
        self.str_attr = "my_str"

        self.group1 = GroupBuilder('group1', {'subgroup1': self.subgroup1})
        self.gb = GroupBuilder('gb', {'group1': self.group1},
                               {'dataset1': self.dataset1}, {
                                   'int_attr': self.int_attr,
                                   'str_attr': self.str_attr
                               }, {'soft_link1': self.soft_link1})
示例#6
0
 def setUpBuilder(self):
     device_builder = GroupBuilder('dev1',
                                   attributes={'neurodata_type': 'Device',
                                               'namespace': 'core',
                                               'help': 'A recording device e.g. amplifier',
                                               'source': 'a test source'})
     return GroupBuilder('elec1',
                         attributes={'neurodata_type': 'ElectrodeGroup',
                                     'namespace': 'core',
                                     'help': 'A physical grouping of channels',
                                     'description': 'a test ElectrodeGroup',
                                     'location': 'a nonexistent place',
                                     'source': 'a test source'},
                         links={
                             'device': LinkBuilder(device_builder, 'device')
                         })
示例#7
0
    def get_table_builder(self):
        self.device_builder = GroupBuilder(
            'dev1',
            attributes={
                'neurodata_type': 'Device',
                'namespace': 'core',
                'help': 'A recording device e.g. amplifier',
                'source': 'a test source'
            })
        self.eg_builder = GroupBuilder(
            'tetrode1',
            attributes={
                'neurodata_type': 'ElectrodeGroup',
                'namespace': 'core',
                'help': 'A physical grouping of channels',
                'description': 'tetrode description',
                'location': 'tetrode location',
                'source': 'a test source'
            },
            links={'device': LinkBuilder(self.device_builder, 'device')})

        data = [
            (1, 1.0, 2.0, 3.0, -1.0, 'CA1', 'none', 'first channel of tetrode',
             ReferenceBuilder(self.eg_builder), 'tetrode1'),
            (2, 1.0, 2.0, 3.0, -2.0, 'CA1',
             'none', 'second channel of tetrode',
             ReferenceBuilder(self.eg_builder), 'tetrode1'),
            (3, 1.0, 2.0, 3.0, -3.0, 'CA1', 'none', 'third channel of tetrode',
             ReferenceBuilder(self.eg_builder), 'tetrode1'),
            (4, 1.0, 2.0, 3.0, -4.0, 'CA1',
             'none', 'fourth channel of tetrode',
             ReferenceBuilder(self.eg_builder), 'tetrode1')
        ]
        return DatasetBuilder(
            'electrodes',
            data,
            attributes={
                'neurodata_type': 'ElectrodeTable',
                'namespace': 'core',
                'help':
                'a table for storing data about extracellular electrodes'
            })
示例#8
0
    def get_plane_segmentation_builder(self):
        self.optchan_builder = GroupBuilder(
            'test_optical_channel',
            attributes={
                'neurodata_type': 'OpticalChannel',
                'namespace': 'core',
                'help':
                'Metadata about an optical channel used to record from an imaging plane',
                'source': 'optical channel source'
            },
            datasets={
                'description':
                DatasetBuilder('description', 'optical channel description'),
                'emission_lambda':
                DatasetBuilder('emission_lambda', 500.)
            },
        )
        self.imgpln_builder = GroupBuilder(
            'imgpln1',
            attributes={
                'neurodata_type': 'ImagingPlane',
                'namespace': 'core',
                'source': 'ophys integration tests',
                'help': 'Metadata about an imaging plane'
            },
            datasets={
                'description':
                DatasetBuilder('description', 'imaging plane description'),
                'device':
                DatasetBuilder('device', 'imaging_device_1'),
                'excitation_lambda':
                DatasetBuilder('excitation_lambda', 600.),
                'imaging_rate':
                DatasetBuilder('imaging_rate', '2.718'),
                'indicator':
                DatasetBuilder('indicator', 'GFP'),
                'manifold':
                DatasetBuilder('manifold', (1, 2, 1, 2, 3),
                               attributes={
                                   'conversion': 4.0,
                                   'unit': 'manifold unit'
                               }),
                'reference_frame':
                DatasetBuilder('reference_frame', 'A frame to refer to'),
                'location':
                DatasetBuilder('location', 'somewhere in the brain')
            },
            groups={'optchan1': self.optchan_builder})
        ts = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
        self.is_builder = GroupBuilder(
            'test_iS',
            attributes={
                'source': 'a hypothetical source',
                'namespace': 'core',
                'neurodata_type': 'ImageSeries',
                'description': 'no description',
                'comments': 'no comments',
                'help': 'Storage object for time-series 2-D image data'
            },
            datasets={
                'timestamps':
                DatasetBuilder('timestamps',
                               ts,
                               attributes={
                                   'unit': 'Seconds',
                                   'interval': 1
                               }),
                'external_file':
                DatasetBuilder('external_file', ['images.tiff'],
                               attributes={'starting_frame': [1, 2, 3]}),
                'format':
                DatasetBuilder('format', 'tiff'),
                'dimension':
                DatasetBuilder('dimension', [2]),
            })

        self.pixel_masks_builder = DatasetBuilder(
            'pixel_masks',
            self.pix_mask,
            attributes={
                'namespace': 'core',
                'neurodata_type': 'PixelMasks',
                'help': 'a concatenated array of pixel masks'
            })

        self.image_masks_builder = DatasetBuilder('image_masks',
                                                  self.img_mask,
                                                  attributes={
                                                      'namespace':
                                                      'core',
                                                      'neurodata_type':
                                                      'ImageMasks',
                                                      'help':
                                                      'an array of image masks'
                                                  })

        self.rois_builder = DatasetBuilder(
            'rois',
            [('1234', RegionBuilder(slice(0, 3), self.pixel_masks_builder),
              RegionBuilder([0], self.image_masks_builder)),
             ('5678', RegionBuilder(slice(3, 5), self.pixel_masks_builder),
              RegionBuilder([1], self.image_masks_builder))],
            attributes={
                'namespace': 'core',
                'neurodata_type': 'ROITable',
                'help': 'A table for storing ROI data'
            })
        ps_builder = GroupBuilder(
            'test_plane_seg_name',
            attributes={
                'neurodata_type': 'PlaneSegmentation',
                'namespace': 'core',
                'source': 'integration test PlaneSegmentation',
                'help': 'Results from segmentation of an imaging plane'
            },
            datasets={
                'description':
                DatasetBuilder('description',
                               'plane segmentation description'),
                'rois':
                self.rois_builder,
                'pixel_masks':
                self.pixel_masks_builder,
                'image_masks':
                self.image_masks_builder,
            },
            groups={
                'reference_images':
                GroupBuilder('reference_images',
                             groups={'test_iS': self.is_builder}),
            },
            links={
                'imaging_plane': LinkBuilder(self.imgpln_builder,
                                             'imaging_plane')
            })
        return ps_builder
示例#9
0
    def setUpBuilder(self):
        optchan_builder = GroupBuilder(
            'optchan1',
            attributes={
                'neurodata_type': 'OpticalChannel',
                'namespace': 'core',
                'help':
                'Metadata about an optical channel used to record from an imaging plane',
                'source': 'unit test TestTwoPhotonSeries'
            },
            datasets={
                'description':
                DatasetBuilder('description', 'a fake OpticalChannel'),
                'emission_lambda':
                DatasetBuilder('emission_lambda', 500.)
            },
        )
        imgpln_builder = GroupBuilder(
            'imgpln1',
            attributes={
                'neurodata_type': 'ImagingPlane',
                'namespace': 'core',
                'help': 'Metadata about an imaging plane',
                'source': 'unit test TestTwoPhotonSeries'
            },
            datasets={
                'description': DatasetBuilder('description',
                                              'a fake ImagingPlane'),
                'device': DatasetBuilder('device', 'imaging_device_1'),
                'excitation_lambda': DatasetBuilder('excitation_lambda', 600.),
                'imaging_rate': DatasetBuilder('imaging_rate', '2.718'),
                'indicator': DatasetBuilder('indicator', 'GFP'),
                'location': DatasetBuilder('location',
                                           'somewhere in the brain')
            },
            groups={'optchan1': optchan_builder})

        data = list(zip(range(10), range(10, 20)))
        timestamps = list(map(lambda x: x / 10, range(10)))
        return GroupBuilder('test_2ps',
                            attributes={
                                'source':
                                'unit test TestTwoPhotonSeries',
                                'pmt_gain':
                                1.7,
                                'scan_line_rate':
                                3.4,
                                'namespace':
                                base.CORE_NAMESPACE,
                                'comments':
                                'no comments',
                                'description':
                                'no description',
                                'neurodata_type':
                                'TwoPhotonSeries',
                                'help':
                                'Image stack recorded from 2-photon microscope'
                            },
                            datasets={
                                'data':
                                DatasetBuilder('data',
                                               data,
                                               attributes={
                                                   'unit': 'image_unit',
                                                   'conversion': 1.0,
                                                   'resolution': 0.0
                                               }),
                                'timestamps':
                                DatasetBuilder('timestamps',
                                               timestamps,
                                               attributes={
                                                   'unit': 'Seconds',
                                                   'interval': 1
                                               }),
                                'format':
                                DatasetBuilder('format', 'raw'),
                                'dimension':
                                DatasetBuilder('dimension', [2]),
                                'field_of_view':
                                DatasetBuilder('field_of_view',
                                               [2.0, 2.0, 5.0]),
                            },
                            links={
                                'imaging_plane':
                                LinkBuilder(imgpln_builder, 'imaging_plane')
                            })
示例#10
0
    def setUpBuilder(self):
        device = GroupBuilder('device_name',
                              attributes={
                                  'neurodata_type': 'Device',
                                  'help': 'A recording device e.g. amplifier',
                                  'namespace': 'core',
                              })

        datasets = [
            DatasetBuilder('slice', data=u'tissue slice'),
            DatasetBuilder('resistance', data=u'something measured in ohms'),
            DatasetBuilder('seal', data=u'sealing method'),
            DatasetBuilder('description', data=u'a fake electrode object'),
            DatasetBuilder('location', data=u'Springfield Elementary School'),
            DatasetBuilder('filtering',
                           data=u'a meaningless free-form text field'),
            DatasetBuilder('initial_access_resistance',
                           data=u'I guess this changes'),
        ]
        elec = GroupBuilder('elec0',
                            attributes={
                                'help':
                                'Metadata about an intracellular electrode',
                                'namespace': 'core',
                                'neurodata_type': 'IntracellularElectrode',
                            },
                            datasets={d.name: d
                                      for d in datasets},
                            links={'device': LinkBuilder(device, 'device')})

        datasets = [
            DatasetBuilder(
                'gain',
                data=0.126,
                attributes={},
            ),
            DatasetBuilder('data',
                           data=[1, 2, 3, 4, 5],
                           attributes={
                               'conversion': 1.0,
                               'resolution': 0.0,
                               'unit': u'A',
                           }),
            DatasetBuilder('starting_time',
                           data=123.6,
                           attributes={
                               'rate': 10000.0,
                               'unit': 'Seconds',
                           }),
        ]
        attributes = {
            'neurodata_type': 'PatchClampSeries',
            'namespace': 'core',
            'comments': u'no comments',
            'help': 'Superclass definition for patch-clamp data',
            'description': u'no description',
            'stimulus_description': u'gotcha ya!',
        }
        attributes['sweep_number'] = 4711
        pcs1 = GroupBuilder(
            'pcs1',
            attributes=attributes,
            links={'electrode': LinkBuilder(elec, 'electrode')},
            datasets={d.name: d
                      for d in datasets},
        )
        attributes['sweep_number'] = 4712
        pcs2a = GroupBuilder(
            'pcs2a',
            attributes=attributes,
            links={'electrode': LinkBuilder(elec, 'electrode')},
            datasets={d.name: d
                      for d in datasets},
        )
        pcs2b = GroupBuilder(
            'pcs2b',
            attributes=attributes,
            links={'electrode': LinkBuilder(elec, 'electrode')},
            datasets={d.name: d
                      for d in datasets},
        )

        column_id = DatasetBuilder(
            'id', [0, 1, 2],
            attributes={
                'neurodata_type': 'ElementIdentifiers',
                'namespace': 'core',
                'help': 'unique identifiers for a list of elements',
            })

        column_series = DatasetBuilder(
            'series',
            attributes={
                'neurodata_type': 'VectorData',
                'namespace': 'core',
                'help': 'Values for a list of elements',
                'description': u'PatchClampSeries with the same sweep number',
            },
            data=[LinkBuilder(pcs) for pcs in (pcs1, pcs2a, pcs2b)])

        column_index = DatasetBuilder(
            'series_index',
            [1, 2, 3],
            attributes={
                'neurodata_type': 'VectorIndex',
                'namespace': 'core',
                'help': 'indexes into a list of values for a list of elements',
                'target': ReferenceBuilder(column_series),
            },
        )

        column_sweep_number = DatasetBuilder(
            'sweep_number',
            data=[4711, 4712, 4712],
            attributes={
                'neurodata_type': 'VectorData',
                'namespace': 'core',
                'help': 'Values for a list of elements',
                'description': u'Sweep number of the entries in that row',
            })

        columns = [column_id, column_series, column_index, column_sweep_number]
        sweep_table = GroupBuilder(
            'sweep_table',
            datasets={c.name: c
                      for c in columns},
            attributes={
                'neurodata_type':
                'SweepTable',
                'namespace':
                'core',
                'colnames': (b'series', b'sweep_number'),
                'help':
                'The table which groups different PatchClampSeries together',
                'description':
                u'A sweep table groups different PatchClampSeries together.',
            },
        )

        return sweep_table
示例#11
0
    def get_table_builder(self):
        self.device_builder = GroupBuilder(
            'dev1',
            attributes={
                'neurodata_type': 'Device',
                'namespace': 'core',
                'help': 'A recording device e.g. amplifier'
            })
        self.eg_builder = GroupBuilder(
            'tetrode1',
            attributes={
                'neurodata_type': 'ElectrodeGroup',
                'namespace': 'core',
                'help': 'A physical grouping of channels',
                'description': 'tetrode description',
                'location': 'tetrode location'
            },
            links={'device': LinkBuilder(self.device_builder, 'device')})

        datasets = [
            DatasetBuilder('id',
                           data=[1, 2, 3, 4],
                           attributes={
                               'help':
                               'unique identifiers for a list of elements',
                               'neurodata_type': 'ElementIdentifiers',
                               'namespace': 'core'
                           }),
            DatasetBuilder(
                'x',
                data=[1.0, 1.0, 1.0, 1.0],
                attributes={
                    'help':
                    'One of many columns that can be added to a DynamicTable',
                    'description': 'the x coordinate of the channel location',
                    'neurodata_type': 'TableColumn',
                    'namespace': 'core'
                }),
            DatasetBuilder(
                'y',
                data=[2.0, 2.0, 2.0, 2.0],
                attributes={
                    'help':
                    'One of many columns that can be added to a DynamicTable',
                    'description': 'the y coordinate of the channel location',
                    'neurodata_type': 'TableColumn',
                    'namespace': 'core'
                }),
            DatasetBuilder(
                'z',
                data=[3.0, 3.0, 3.0, 3.0],
                attributes={
                    'help':
                    'One of many columns that can be added to a DynamicTable',
                    'description': 'the z coordinate of the channel location',
                    'neurodata_type': 'TableColumn',
                    'namespace': 'core'
                }),
            DatasetBuilder(
                'imp',
                data=[-1.0, -2.0, -3.0, -4.0],
                attributes={
                    'help':
                    'One of many columns that can be added to a DynamicTable',
                    'description': 'the impedance of the channel',
                    'neurodata_type': 'TableColumn',
                    'namespace': 'core'
                }),
            DatasetBuilder(
                'location',
                data=['CA1', 'CA1', 'CA1', 'CA1'],
                attributes={
                    'help':
                    'One of many columns that can be added to a DynamicTable',
                    'description':
                    'the location of channel within the subject e.g. brain region',
                    'neurodata_type': 'TableColumn',
                    'namespace': 'core'
                }),
            DatasetBuilder(
                'filtering',
                data=['none', 'none', 'none', 'none'],
                attributes={
                    'help':
                    'One of many columns that can be added to a DynamicTable',
                    'description': 'description of hardware filtering',
                    'neurodata_type': 'TableColumn',
                    'namespace': 'core'
                }),
            DatasetBuilder(
                'group',
                data=[
                    ReferenceBuilder(self.eg_builder),
                    ReferenceBuilder(self.eg_builder),
                    ReferenceBuilder(self.eg_builder),
                    ReferenceBuilder(self.eg_builder)
                ],
                attributes={
                    'help':
                    'One of many columns that can be added to a DynamicTable',
                    'description':
                    'a reference to the ElectrodeGroup this electrode is a part of',
                    'neurodata_type': 'TableColumn',
                    'namespace': 'core'
                }),
            DatasetBuilder(
                'group_name',
                data=['tetrode1', 'tetrode1', 'tetrode1', 'tetrode1'],
                attributes={
                    'help':
                    'One of many columns that can be added to a DynamicTable',
                    'description':
                    'the name of the ElectrodeGroup this electrode is a part of',
                    'neurodata_type': 'TableColumn',
                    'namespace': 'core'
                }),
        ]
        return GroupBuilder('electrodes',
                            datasets={d.name: d
                                      for d in datasets},
                            attributes={
                                'colnames':
                                ('x', 'y', 'z', 'imp', 'location', 'filtering',
                                 'group', 'group_name'),
                                'description':
                                'metadata about extracellular electrodes',
                                'neurodata_type':
                                'DynamicTable',
                                'namespace':
                                'core',
                                'help':
                                'A column-centric table'
                            })
示例#12
0
    def get_plane_segmentation_builder(self):
        self.optchan_builder = GroupBuilder(
            'test_optical_channel',
            attributes={
                'neurodata_type': 'OpticalChannel',
                'namespace': 'core',
                'help': 'Metadata about an optical channel used to record from an imaging plane'},
            datasets={
                'description': DatasetBuilder('description', 'optical channel description'),
                'emission_lambda': DatasetBuilder('emission_lambda', 500.)},
        )
        device_builder = GroupBuilder('dev1',
                                      attributes={'neurodata_type': 'Device',
                                                  'namespace': 'core',
                                                  'help': 'A recording device e.g. amplifier'})
        self.imgpln_builder = GroupBuilder(
            'imgpln1',
            attributes={
                'neurodata_type': 'ImagingPlane',
                'namespace': 'core',
                'help': 'Metadata about an imaging plane'},
            datasets={
                'description': DatasetBuilder('description', 'imaging plane description'),
                'excitation_lambda': DatasetBuilder('excitation_lambda', 600.),
                'imaging_rate': DatasetBuilder('imaging_rate', 300.),
                'indicator': DatasetBuilder('indicator', 'GFP'),
                'manifold': DatasetBuilder('manifold', (1, 2, 1, 2, 3),
                                           attributes={'conversion': 4.0, 'unit': 'manifold unit'}),
                'reference_frame': DatasetBuilder('reference_frame', 'A frame to refer to'),
                'location': DatasetBuilder('location', 'somewhere in the brain')},
            groups={
                'optchan1': self.optchan_builder
            },
            links={
                'device': LinkBuilder(device_builder, 'device')
            }
        )
        ts = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
        self.is_builder = GroupBuilder('test_iS',
                                       attributes={'namespace': 'core',
                                                   'neurodata_type': 'ImageSeries',
                                                   'description': 'no description',
                                                   'comments': 'no comments',
                                                   'help': 'Storage object for time-series 2-D image data'},
                                       datasets={'timestamps': DatasetBuilder('timestamps', ts,
                                                                              attributes={'unit': 'Seconds',
                                                                                          'interval': 1}),
                                                 'external_file': DatasetBuilder('external_file', ['images.tiff'],
                                                                                 attributes={
                                                                                    'starting_frame': [1, 2, 3]}),
                                                 'format': DatasetBuilder('format', 'tiff'),
                                                 'dimension': DatasetBuilder('dimension', [2]),
                                                 })

        self.pixel_masks_builder = DatasetBuilder('pixel_mask', self.pix_mask,
                                                  attributes={
                                                   'namespace': 'core',
                                                   'neurodata_type': 'VectorData',
                                                   'description': 'Pixel masks for each ROI',
                                                   'help': 'Values for a list of elements'})

        self.pxmsk_index_builder = DatasetBuilder('pixel_mask_index', self.pxmsk_index,
                                                  attributes={
                                                   'namespace': 'core',
                                                   'neurodata_type': 'VectorIndex',
                                                   'target': ReferenceBuilder(self.pixel_masks_builder),
                                                   'help': 'indexes into a list of values for a list of elements'})

        self.image_masks_builder = DatasetBuilder('image_mask', self.img_mask,
                                                  attributes={
                                                   'namespace': 'core',
                                                   'neurodata_type': 'VectorData',
                                                   'description': 'Image masks for each ROI',
                                                   'help': 'Values for a list of elements'})

        ps_builder = GroupBuilder(
            'test_plane_seg_name',
            attributes={
                'neurodata_type': 'PlaneSegmentation',
                'namespace': 'core',
                'description': 'plane segmentation description',
                'colnames': ('image_mask', 'pixel_mask'),
                'help': 'Results from segmentation of an imaging plane'},
            datasets={
                'id': DatasetBuilder('id', data=[0, 1],
                                     attributes={'help': 'unique identifiers for a list of elements',
                                                 'namespace': 'core',
                                                 'neurodata_type': 'ElementIdentifiers'}),
                'pixel_mask': self.pixel_masks_builder,
                'pixel_mask_index': self.pxmsk_index_builder,
                'image_mask': self.image_masks_builder,
            },
            groups={
                'reference_images': GroupBuilder('reference_images', groups={'test_iS': self.is_builder}),
            },
            links={
                'imaging_plane': LinkBuilder(self.imgpln_builder, 'imaging_plane')
            }
        )
        return ps_builder
示例#13
0
    def setUp(self):
        type_map = get_type_map()
        self.manager = BuildManager(type_map)
        self.path = "test_pynwb_io_hdf5.h5"
        self.start_time = datetime(1970, 1, 1, 12, 0, 0)
        self.create_date = datetime(2017, 4, 15, 12, 0, 0)

        self.ts_builder = GroupBuilder(
            'test_timeseries',
            attributes={
                'ancestry': 'TimeSeries',
                'source': 'example_source',
                'neurodata_type': 'TimeSeries',
                'int_array_attribute': [0, 1, 2, 3],
                'str_array_attribute': ['a', 'b', 'c', 'd'],
                'help': 'General purpose TimeSeries'
            },
            datasets={
                'data':
                DatasetBuilder('data',
                               list(range(100, 200, 10)),
                               attributes={
                                   'unit': 'SIunit',
                                   'conversion': 1.0,
                                   'resolution': 0.1
                               }),
                'timestamps':
                DatasetBuilder('timestamps',
                               list(range(10)),
                               attributes={
                                   'unit': 'Seconds',
                                   'interval': 1
                               })
            })
        self.ts = TimeSeries('test_timeseries',
                             'example_source',
                             list(range(100, 200, 10)),
                             unit='SIunit',
                             resolution=0.1,
                             timestamps=list(range(10)))
        self.manager.prebuilt(self.ts, self.ts_builder)
        self.builder = GroupBuilder(
            'root',
            source=self.path,
            groups={
                'acquisition':
                GroupBuilder('acquisition',
                             groups={
                                 'timeseries':
                                 GroupBuilder('timeseries',
                                              groups={
                                                  'test_timeseries':
                                                  self.ts_builder
                                              }),
                                 'images':
                                 GroupBuilder('images')
                             }),
                'analysis':
                GroupBuilder('analysis'),
                'epochs':
                GroupBuilder('epochs'),
                'general':
                GroupBuilder('general'),
                'processing':
                GroupBuilder('processing',
                             groups={
                                 'test_module':
                                 GroupBuilder('test_module',
                                              links={
                                                  'test_timeseries_link':
                                                  LinkBuilder(
                                                      self.ts_builder,
                                                      'test_timeseries_link')
                                              })
                             }),
                'stimulus':
                GroupBuilder('stimulus',
                             groups={
                                 'presentation': GroupBuilder('presentation'),
                                 'templates': GroupBuilder('templates')
                             })
            },
            datasets={
                'file_create_date':
                DatasetBuilder('file_create_date', [str(self.create_date)]),
                'identifier':
                DatasetBuilder('identifier', 'TEST123'),
                'session_description':
                DatasetBuilder('session_description', 'a test NWB File'),
                'nwb_version':
                DatasetBuilder('nwb_version', '1.0.6'),
                'session_start_time':
                DatasetBuilder('session_start_time', str(self.start_time))
            },
            attributes={'neurodata_type': 'NWBFile'})