예제 #1
0
 def setUpElectricalSeriesBuilders(self):
     table_builder = TestElectricalSeriesIO.get_table_builder(self)
     data = list(zip(range(10), range(10, 20)))
     timestamps = list(map(lambda x: x/10, range(10)))
     es1 = GroupBuilder('test_eS1',
                         attributes={'source': 'a hypothetical source',
                                     'namespace': base.CORE_NAMESPACE,
                                     'comments': 'no comments',
                                     'description': 'no description',
                                     'neurodata_type': 'ElectricalSeries',
                                     'help': 'Stores acquired voltage data from extracellular recordings'},
                         datasets={'data': DatasetBuilder('data',
                                                          data,
                                                          attributes={'unit': 'volt',
                                                                      'conversion': 1.0,
                                                                      'resolution': 0.0}),
                                   'timestamps': DatasetBuilder('timestamps',
                                                                timestamps,
                                                                attributes={'unit': 'Seconds', 'interval': 1}),
                                   'electrodes': DatasetBuilder('electrodes', data=[0, 2],
                                                                attributes={
                                                                   'neurodata_type': 'DynamicTableRegion',
                                                                   'table': ReferenceBuilder(table_builder),
                                                                   'namespace': 'core',
                                                                   'description': 'the first and third electrodes',
                                                                   'help': 'a subset (i.e. slice or region) of a DynamicTable'})})  # noqa: E501
     data = list(zip(reversed(range(10)), reversed(range(10, 20))))
     es2 = GroupBuilder('test_eS2',
                         attributes={'source': 'a hypothetical source',
                                     'namespace': base.CORE_NAMESPACE,
                                     'comments': 'no comments',
                                     'description': 'no description',
                                     'neurodata_type': 'ElectricalSeries',
                                     'help': 'Stores acquired voltage data from extracellular recordings'},
                         datasets={'data': DatasetBuilder('data',
                                                          data,
                                                          attributes={'unit': 'volt',
                                                                      'conversion': 1.0,
                                                                      'resolution': 0.0}),
                                   'timestamps': DatasetBuilder('timestamps',
                                                                timestamps,
                                                                attributes={'unit': 'Seconds', 'interval': 1}),
                                   'electrodes': DatasetBuilder('electrodes', data=[1, 3],
                                                                attributes={
                                                                   'neurodata_type': 'DynamicTableRegion',
                                                                   'namespace': 'core',
                                                                   'table':  ReferenceBuilder(table_builder),
                                                                   'description': 'the second and fourth electrodes',
                                                                   'help': 'a subset (i.e. slice or region) of a DynamicTable'})})  # noqa: E501
     return (es1, es2)
예제 #2
0
 def setUpBuilder(self):
     ps_builder = TestPlaneSegmentation.get_plane_segmentation_builder(self)
     return GroupBuilder(
         'test_roi_response_series',
         attributes={
             'namespace': base.CORE_NAMESPACE,
             'comments': 'no comments',
             'description': 'no description',
             'neurodata_type': 'RoiResponseSeries',
             'help': ('ROI responses over an imaging plane. Each element on the second dimension of data[] '
                      'should correspond to the signal from one ROI')},
         datasets={
             'data': DatasetBuilder(
                 'data', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
                 attributes={
                     'unit': 'lumens',
                     'conversion': 1.0,
                     'resolution': 0.0}
             ),
             'timestamps': DatasetBuilder('timestamps', [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
                                          attributes={'unit': 'Seconds', 'interval': 1}),
             'rois': DatasetBuilder('rois', data=[0],
                                    attributes={'help': 'a subset (i.e. slice or region) of a DynamicTable',
                                                'description': 'the first of two ROIs',
                                                'table': ReferenceBuilder(ps_builder),
                                                'namespace': 'core',
                                                'neurodata_type': 'DynamicTableRegion'}),
         })
예제 #3
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'
            })
예제 #4
0
 def setUpBuilder(self):
     ids_builder = DatasetBuilder(
         'id', [0, 1],
         attributes={
             'neurodata_type': 'ElementIdentifiers',
             'namespace': 'core',
             'help': 'unique identifiers for a list of elements'
         })
     st_builder = DatasetBuilder('spike_times', [0, 1, 2, 3, 4, 5],
                                 attributes={
                                     'neurodata_type': 'VectorData',
                                     'namespace': 'core',
                                     'description':
                                     'the spike times for each unit',
                                     'help': 'Values for a list of elements'
                                 })
     sti_builder = DatasetBuilder(
         'spike_times_index', [3, 6],
         attributes={
             'neurodata_type': 'VectorIndex',
             'namespace': 'core',
             'target': ReferenceBuilder(st_builder),
             'help': 'indexes into a list of values for a list of elements'
         })
     return GroupBuilder('UnitsTest',
                         attributes={
                             'neurodata_type': 'Units',
                             'namespace': 'core',
                             'help': 'Data about spiking units',
                             'description':
                             'a simple table for testing Units',
                             'colnames': ('spike_times', )
                         },
                         datasets={
                             'id': ids_builder,
                             'spike_times': st_builder,
                             'spike_times_index': sti_builder
                         })
예제 #5
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
예제 #6
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'
                            })
예제 #7
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