Skip to content

Commit

Permalink
Merge branch 'dev' into mask_conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
bendichter authored Dec 29, 2018
2 parents 6a6843e + b851088 commit 888b76f
Show file tree
Hide file tree
Showing 17 changed files with 466 additions and 50 deletions.
14 changes: 6 additions & 8 deletions docs/gallery/general/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@
# for the column and a description of what the column stores. You do not need to supply data
# type, as this will inferred.
# Once all columns have been added, trial data can be populated using :py:func:`~pynwb.file.NWBFile.add_trial`.
# This method takes a dict with keys that correspond to column names.
#
# Lets add an additional column and some trial data.

Expand All @@ -177,22 +176,21 @@
# and :py:func:`~pynwb.file.NWBFile.add_unit_column`. These methods work like the methods for adding
# trials described :ref:`above <basic_trials>`
#
# By default, NWBFile only requires a unique identifier for each unit. Additional columns
# can be added using :py:func:`~pynwb.file.NWBFile.add_unit_column`. Like
# By default, NWBFile only requires a unique identifier for each unit. Optional values for each unit
# are: `spike_times`, `electrodes`, `electrode_group`, `waveform_mean`, and `waveform_sd`.
# Additional columns can be added using :py:func:`~pynwb.file.NWBFile.add_unit_column`. Like
# :py:func:`~pynwb.file.NWBFile.add_trial_column`, this method also takes a name
# for the column, a description of what the column stores and does not need a data type.
# Once all columns have been added, unit data can be populated using :py:func:`~pynwb.file.NWBFile.add_unit`.
# Again, like :py:func:`~pynwb.file.NWBFile.add_trial_column`, this method takes a dict with keys that correspond
# to column names.
#
# Lets specify some unit metadata and then add some units

nwbfile.add_unit_column('location', 'the anatomical location of this unit')
nwbfile.add_unit_column('quality', 'the quality for the inference of this unit')

nwbfile.add_unit(id=1, location='CA1', quality=0.95)
nwbfile.add_unit(id=2, location='CA3', quality=0.85)
nwbfile.add_unit(id=3, location='CA1', quality=0.90)
nwbfile.add_unit(id=1, spike_times=[2.2, 3.0, 4.5], location='CA1', quality=0.95)
nwbfile.add_unit(id=2, spike_times=[2.2, 3.0], location='CA3', quality=0.85)
nwbfile.add_unit(id=3, spike_times=[1.2, 2.3, 3.3, 4.5], location='CA1', quality=0.90)

####################
# .. _units_fields_ref:
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ six==1.11.0
tox==3.0.0
traceback2==1.4.0
unittest2==1.1.0
urllib3==1.22
urllib3==1.23
virtualenv==15.2.0
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ python-dateutil==2.7.2
requests==2.20.0
ruamel.yaml==0.15.37
six==1.11.0
urllib3==1.22
urllib3==1.23
pandas==0.23.4
19 changes: 19 additions & 0 deletions src/pynwb/data/nwb.ecephys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@ groups:
- - null
- null
- null
- name: timestamps
dtype: float64
doc: 'Timestamps for samples stored in data.COMMENT: Timestamps here have all
been corrected to the common experiment master-clock. Time is stored as seconds
and all timestamps are relative to experiment start time. This is added here so
that the timestamps is required for SpikeEventTimes.'
attributes:
- name: interval
dtype: int32
doc: Value is '1'
value: 1
- name: unit
dtype: text
doc: Value is 'Seconds'
value: Seconds
dims:
- num_times
shape:
- null
- neurodata_type_def: ClusterWaveforms
neurodata_type_inc: NWBDataInterface
doc: 'The mean waveform shape, including standard deviation, of the different clusters.
Expand Down
4 changes: 4 additions & 0 deletions src/pynwb/data/nwb.file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ groups:
dtype: text
doc: Age of subject
quantity: '?'
- name: date_of_birth
dtype: isodatetime
doc: can be supplied instead of age
quantity: '?'
- name: description
dtype: text
doc: Description of subject and where subject came from (e.g., breeder, if
Expand Down
98 changes: 97 additions & 1 deletion src/pynwb/data/nwb.misc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,86 @@ groups:
- num_times
shape:
- null
- neurodata_type_def: DecompositionSeries
neurodata_type_inc: TimeSeries
doc: Holds spectral analysis of a timeseries. For instance of LFP or a speech signal
datasets:
- name: data
dtype: float
doc: The data goes here
shape:
- null
- null
- null
dims:
- num_times
- num_channels
- num_bands
- name: metric
dtype: text
doc: 'recommended: phase, amplitude, power'
links:
- name: source_timeseries
doc: HDF5 link to TimesSeries that this data was calculated from. Metadata
about electrodes and their position can be read from that ElectricalSeries so
it's not necessary to store that information here
target_type: TimeSeries
groups:
- neurodata_type_inc: DynamicTable
name: bands
doc: A table for describing the bands that this series was generated from. There
should be one row in this table for each band
datasets:
- neurodata_type_inc: VectorData
name: band_name
dtype: text
doc: the name of the band e.g. theta
attributes:
- name: description
dtype: text
doc: value is 'the name of the band e.g. theta'
value: the name of the band e.g. theta
- neurodata_type_inc: VectorData
name: band_limits
dtype: float
shape:
- null
- 2
dims:
- num_bands
- low, high
doc: Low and high limit of each band in Hz. If it is a Gaussian filter, use 2 SD on either side of the center
attributes:
- name: description
dtype: text
doc: value is 'Low and high limit of each band in Hz. If it is a Gaussian filter, use 2 SD on either side of the center'
value: Low and high limit of each band in Hz. If it is a Gaussian filter, use 2 SD on either side of the center
- neurodata_type_inc: VectorData
name: band_mean
dtype: float
shape:
- null
dims:
- num_bands
doc: The mean Gaussian filters in Hz
attributes:
- name: description
dtype: text
doc: The mean Gaussian filters in Hz
value: The mean Gaussian filters in Hz
- neurodata_type_inc: VectorData
name: band_stdev
dtype: float
shape:
- null
dims:
- num_bands
doc: The standard devaition of Gaussian filters in Hz
attributes:
- name: description
dtype: text
doc: The standard devaition of Gaussian filters in Hz
value: The standard devaition of Gaussian filters in Hz
- neurodata_type_def: Units
neurodata_type_inc: DynamicTable
doc: Data about spiking units. Event times of observed units (e.g. cell, synapse, etc.)
Expand All @@ -127,9 +207,25 @@ groups:
quantity: '?'
- neurodata_type_inc: VectorData
name: spike_times
dtype: double
doc: the spike times for each unit
quantity: '?'
- neurodata_type_inc: DynamicTableRegion
- neurodata_type_inc: VectorIndex
name: obs_intervals_index
doc: the index into the obs_intervals dataset
quantity: '?'
- neurodata_type_inc: VectorData
name: obs_intervals
doc: the observation intervals for each unit
quantity: '?'
dtype: double
dims:
- num_intervals
- start|end
shape:
- null
- 2
- neurodata_type_inc: VectorIndex
name: electrodes_index
doc: the index into electrodes
quantity: '?'
Expand Down
2 changes: 1 addition & 1 deletion src/pynwb/data/nwb.namespace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ namespaces:
- source: nwb.ogen.yaml
- source: nwb.ophys.yaml
- source: nwb.retinotopy.yaml
version: 1.2.0
version: 2.0.0b
20 changes: 13 additions & 7 deletions src/pynwb/ecephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .base import TimeSeries, _default_resolution, _default_conversion
from .core import NWBContainer, NWBDataInterface, MultiContainerInterface, DynamicTableRegion
from .device import Device
from .misc import DecompositionSeries


@register_class('ElectrodeGroup', CORE_NAMESPACE)
Expand Down Expand Up @@ -281,13 +282,18 @@ class LFP(MultiContainerInterface):
ElectricalSeries description or comments field.
"""

__clsconf__ = {
'attr': 'electrical_series',
'type': ElectricalSeries,
'add': 'add_electrical_series',
'get': 'get_electrical_series',
'create': 'create_electrical_series',
}
__clsconf__ = [
{'attr': 'electrical_series',
'type': ElectricalSeries,
'add': 'add_electrical_series',
'get': 'get_electrical_series',
'create': 'create_electrical_series'},

{'attr': 'decomposition_series',
'type': DecompositionSeries,
'add': 'add_decomposition_series',
'get': 'get_decomposition_series',
'create': 'create_decomposition_series'}]

__help = ("LFP data from one or more channels. Filter properties "
"should be noted in the ElectricalSeries")
Expand Down
10 changes: 9 additions & 1 deletion src/pynwb/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Subject(NWBContainer):
'species',
'subject_id',
'weight',
'date_of_birth'
)

@docval({'name': 'age', 'type': str, 'doc': 'the age of the subject', 'default': None},
Expand All @@ -53,7 +54,9 @@ class Subject(NWBContainer):
{'name': 'sex', 'type': str, 'doc': 'the sex of the subject', 'default': None},
{'name': 'species', 'type': str, 'doc': 'the species of the subject', 'default': None},
{'name': 'subject_id', 'type': str, 'doc': 'a unique identifier for the subject', 'default': None},
{'name': 'weight', 'type': str, 'doc': 'the weight of the subject', 'default': None})
{'name': 'weight', 'type': str, 'doc': 'the weight of the subject', 'default': None},
{'name': 'date_of_birth', 'type': datetime, 'default': None,
'doc': 'datetime of date of birth. May be supplied instead of age.'})
def __init__(self, **kwargs):
kwargs['name'] = 'subject'
pargs, pkwargs = fmt_docval_args(super(Subject, self).__init__, kwargs)
Expand All @@ -65,6 +68,11 @@ def __init__(self, **kwargs):
self.species = getargs('species', kwargs)
self.subject_id = getargs('subject_id', kwargs)
self.weight = getargs('weight', kwargs)
date_of_birth = getargs('date_of_birth', kwargs)
if date_of_birth and date_of_birth.tzinfo is None:
self.date_of_birth = _add_missing_timezone(date_of_birth)
else:
self.date_of_birth = date_of_birth


@register_class('NWBFile', CORE_NAMESPACE)
Expand Down
Loading

0 comments on commit 888b76f

Please sign in to comment.