Skip to content

Commit

Permalink
Merge pull request #1213 from NeurodataWithoutBorders/schema_2.2.3
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Ly <[email protected]>
Co-authored-by: Ben Dichter <[email protected]>
  • Loading branch information
rly and bendichter authored May 28, 2020
2 parents 16e73d9 + 887acce commit c124687
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 24 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# PyNWB Changelog

## PyNWB 1.3.1 (Upcoming)
## PyNWB 1.3.1 (May 28, 2020)

### Bug fixes:
- Fix bugged `Device` constructor. @rly (#1209)
- Fix link to code of conduct page in docs. @rly (#1229)
- Fix docs for get_type_map. @oruebel (#1233)
- Pass file object to parent when loading namespaces (#1242)

### Internal improvements:
- Update CI to use supported MacOS version. @rly (#1211)
- Clean up tests to remove conversion warnings and use keyword args. @rly (#1202)
- Fix flake8 errors. @rly (#1235)
- Add changelog. @rly (#1215)
- Update release process with notes about coordinating with nwb-schema. @rly (#1214)
- Inform which unit value is actually overwritten. @yarikoptic (#1219)
- Do not print out logging.DEBUG statements to stdout for test.py. @rly (#1240)
- Add support for nwb-schema 2.2.4. @rly (#1213)
- Make `ImagingPlane.imaging_rate` optional. This moves the `imaging_rate` argument down the list of constructor
arguments for `ImagingPlane.__init__`. This will break existing code that calls the constructor of
`ImagingPlane` with at least 6 positional arguments, such that one positional argument matches `imaging_rate`.

## PyNWB 1.3.0 (Mar. 4, 2020)

Expand Down
11 changes: 6 additions & 5 deletions docs/gallery/domain/ophys.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
from datetime import datetime
from dateutil.tz import tzlocal

import numpy as np

from pynwb import NWBFile
from pynwb.ophys import TwoPhotonSeries, OpticalChannel, ImageSegmentation, Fluorescence
from pynwb.device import Device
Expand Down Expand Up @@ -53,9 +51,12 @@
device = Device('imaging_device_1')
nwbfile.add_device(device)
optical_channel = OpticalChannel('my_optchan', 'description', 500.)
imaging_plane = nwbfile.create_imaging_plane('my_imgpln', optical_channel, 'a very interesting part of the brain',
device, 600., 300., 'GFP', 'my favorite brain location',
np.ones((5, 5, 3)), 4.0, 'manifold unit', 'A frame to refer to')
imaging_plane = nwbfile.create_imaging_plane('my_imgpln', optical_channel,
description='a very interesting part of the brain',
device=device, excitation_lambda=600., imaging_rate=300., indicator='GFP',
location='my favorite brain location',
reference_frame='A frame to refer to',
grid_spacing=(.01, .01))


####################
Expand Down
4 changes: 3 additions & 1 deletion src/pynwb/ophys.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ class ImagingPlane(NWBContainer):
{'name': 'description', 'type': str, 'doc': 'Description of this ImagingPlane.'}, # required
{'name': 'device', 'type': Device, 'doc': 'the device that was used to record'}, # required
{'name': 'excitation_lambda', 'type': 'float', 'doc': 'Excitation wavelength in nm.'}, # required
{'name': 'imaging_rate', 'type': 'float', 'doc': 'Rate images are acquired, in Hz.'}, # required
{'name': 'indicator', 'type': str, 'doc': 'Calcium indicator'}, # required
{'name': 'location', 'type': str, 'doc': 'Location of image plane.'}, # required
{'name': 'imaging_rate', 'type': 'float',
'doc': 'Rate images are acquired, in Hz. If the corresponding TimeSeries is present, the rate should be '
'stored there instead.', 'default': None},
{'name': 'manifold', 'type': 'array_data',
'doc': ('DEPRECATED: Physical position of each pixel. size=("height", "width", "xyz"). '
'Deprecated in favor of origin_coords and grid_spacing.'),
Expand Down
7 changes: 5 additions & 2 deletions tests/integration/hdf5/test_ophys.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,11 @@ def buildPlaneSegmentationNoRois(self):
external_file=['images.tiff'],
starting_frame=[1, 2, 3], format='tiff', timestamps=ts)
self.device = Device(name='dev1')
self.optical_channel = OpticalChannel(name='test_optical_channel', description='optical channel description',
emission_lambda=500.)
self.optical_channel = OpticalChannel(
name='test_optical_channel',
description='optical channel description',
emission_lambda=500.
)
self.imaging_plane = ImagingPlane(
name='test_imaging_plane',
optical_channel=self.optical_channel,
Expand Down
33 changes: 19 additions & 14 deletions tests/unit/test_ophys.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ def CreatePlaneSegmentation():

oc = OpticalChannel('test_optical_channel', 'description', 500.)
device = Device(name='device_name')
ip = ImagingPlane('test_imaging_plane', oc, 'description', device, 600.,
300., 'indicator', 'location', reference_frame='reference_frame')
ip = ImagingPlane(name='test_imaging_plane', optical_channel=oc, description='description', device=device,
excitation_lambda=600., imaging_rate=300., indicator='indicator', location='location',
reference_frame='reference_frame')

pS = PlaneSegmentation('description', ip, 'test_name', iSS)
pS.add_roi(pixel_mask=pix_mask[0:3], image_mask=img_mask[0])
Expand All @@ -36,8 +37,9 @@ def test_init(self):
self.assertEqual(oc.emission_lambda, 500.)

device = Device(name='device_name')
ip = ImagingPlane('test_imaging_plane', oc, 'description', device, 600.,
300., 'indicator', 'location', reference_frame='reference_frame',
ip = ImagingPlane('test_imaging_plane', oc, description='description', device=device, excitation_lambda=600.,
imaging_rate=300., indicator='indicator', location='location',
reference_frame='reference_frame',
origin_coords=[10, 20], origin_coords_unit='oc_unit',
grid_spacing=[1, 2, 3], grid_spacing_unit='gs_unit')
self.assertEqual(ip.optical_channel[0], oc)
Expand Down Expand Up @@ -69,8 +71,9 @@ def test_init(self):
def test_args(self):
oc = OpticalChannel('test_name', 'description', 500.)
device = Device(name='device_name')
ip = ImagingPlane('test_imaging_plane', oc, 'description', device, 600.,
300., 'indicator', 'location', reference_frame='reference_frame')
ip = ImagingPlane('test_imaging_plane', oc, description='description', device=device, excitation_lambda=600.,
imaging_rate=300., indicator='indicator', location='location',
reference_frame='reference_frame')
with self.assertRaises(ValueError): # no data or external file
TwoPhotonSeries('test_tPS', unit='unit', field_of_view=[2., 3.],
imaging_plane=ip, pmt_gain=1.0, scan_line_rate=2.0,
Expand All @@ -85,8 +88,9 @@ def test_manifold_deprecated(self):

msg = "The 'manifold' argument is deprecated in favor of 'origin_coords' and 'grid_spacing'."
with self.assertWarnsWith(DeprecationWarning, msg):
ImagingPlane('test_imaging_plane', oc, 'description', device, 600., 300., 'indicator', 'location',
(1, 1, (2, 2, 2)))
ImagingPlane('test_imaging_plane', oc, description='description', device=device, excitation_lambda=600.,
imaging_rate=300., indicator='indicator', location='location',
manifold=(1, 1, (2, 2, 2)))

def test_conversion_deprecated(self):
oc = OpticalChannel('test_name', 'description', 500.)
Expand All @@ -97,8 +101,8 @@ def test_conversion_deprecated(self):

msg = "The 'conversion' argument is deprecated in favor of 'origin_coords' and 'grid_spacing'."
with self.assertWarnsWith(DeprecationWarning, msg):
ImagingPlane('test_imaging_plane', oc, 'description', device, 600., 300., 'indicator', 'location',
None, 2.0)
ImagingPlane('test_imaging_plane', oc, description='description', device=device, excitation_lambda=600.,
imaging_rate=300., indicator='indicator', location='location', conversion=2.0)

def test_unit_deprecated(self):
oc = OpticalChannel('test_name', 'description', 500.)
Expand All @@ -109,8 +113,8 @@ def test_unit_deprecated(self):

msg = "The 'unit' argument is deprecated in favor of 'origin_coords_unit' and 'grid_spacing_unit'."
with self.assertWarnsWith(DeprecationWarning, msg):
ImagingPlane('test_imaging_plane', oc, 'description', device, 600., 300., 'indicator', 'location',
None, 1.0, 'my_unit')
ImagingPlane('test_imaging_plane', oc, description='description', device=device, excitation_lambda=600.,
imaging_rate=300., indicator='indicator', location='location', conversion=1.0, unit='my_unit')


class MotionCorrectionConstructor(TestCase):
Expand Down Expand Up @@ -190,8 +194,9 @@ def getBoilerPlateObjects(self):

device = Device(name='device_name')
oc = OpticalChannel('test_optical_channel', 'description', 500.)
ip = ImagingPlane('test_imaging_plane', oc, 'description', device, 600.,
300., 'indicator', 'location', reference_frame='reference_frame')
ip = ImagingPlane('test_imaging_plane', oc, description='description', device=device, excitation_lambda=600.,
imaging_rate=300., indicator='indicator', location='location',
reference_frame='reference_frame')
return iSS, ip

def create_basic_plane_segmentation(self):
Expand Down

0 comments on commit c124687

Please sign in to comment.