Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create units submodule #1465

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/api_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ Relationships:
.. testsetup:: *

from neo import SpikeTrain
import quantities as pq
import neo.units
8 changes: 4 additions & 4 deletions doc/source/read_and_analyze.rst
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ objects directly, e.g.:

In [20]: import numpy as np

In [21]: from quantities import mV, kHz
In [21]: from neo.units import mV, kHz

In [22]: from neo import AnalogSignal

Expand All @@ -245,7 +245,7 @@ specify the array of times at which the signal was sampled.

.. ipython::

In [25]: from quantities import ms, nA
In [25]: from neo.units import ms, nA

In [26]: from neo import IrregularlySampledSignal

Expand Down Expand Up @@ -336,7 +336,7 @@ It behaves similarly to :class:`AnalogSignal`, but in 3D rather than 2D.

.. ipython::

In [38]: from quantities import Hz, micrometer
In [38]: from neo.units import Hz, micrometer

In [39]: from neo import ImageSequence

Expand Down Expand Up @@ -367,7 +367,7 @@ For any metadata not covered by the required or recommended fields, additional a

.. ipython::

In [43]: from quantities import um as µm
In [43]: from neo.units import um as µm

In [44]: signal.annotate(pipette_tip_diameter=1.5 * µm)

Expand Down
4 changes: 2 additions & 2 deletions examples/plot_imageseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from neo.core import ImageSequence
from neo.core import RectangularRegionOfInterest, CircularRegionOfInterest, PolygonRegionOfInterest
import matplotlib.pyplot as plt
import quantities as pq
import neo.units

import random

Expand All @@ -33,7 +33,7 @@
# we then make our image sequence and pull out our results from the
# image_seq

image_seq = ImageSequence(l, sampling_rate=500 * pq.Hz, spatial_scale="m", units="V")
image_seq = ImageSequence(l, sampling_rate=500 * neo.units.Hz, spatial_scale="m", units="V")

result = image_seq.signal_from_region(
CircularRegionOfInterest(image_seq, 50, 50, 25),
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_multi_tetrode_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from itertools import cycle
import numpy as np
from quantities import ms, mV, kHz
from neo.units import ms, mV, kHz
import matplotlib.pyplot as plt
from neo import Block, Segment, ChannelView, Group, SpikeTrain, AnalogSignal

Expand Down
6 changes: 3 additions & 3 deletions examples/plot_read_proxy_with_lazy_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import urllib
import neo
import quantities as pq
import neo.units
import numpy as np


Expand Down Expand Up @@ -68,8 +68,8 @@ def apply_my_fancy_average(sig_list):
# Let's set our limits for both cases. We will
# use quantities to include time dimensions.

lim_start = -20 * pq.ms # 20 milliseconds before
lim_end = +20 * pq.ms # 20 milliseconds after
lim_start = -20 * neo.units.ms # 20 milliseconds before
lim_end = +20 * neo.units.ms # 20 milliseconds after

##################################################
# We start with eager (where `lazy=False`.) Everything
Expand Down
4 changes: 2 additions & 2 deletions examples/plot_roi_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from neo.core import CircularRegionOfInterest, RectangularRegionOfInterest, PolygonRegionOfInterest, ImageSequence
from numpy.random import rand
import random
import quantities as pq
import neo.units

##################################################################
# First we create our image_sequence. Let's generate some data
Expand All @@ -32,7 +32,7 @@
l[frame][y].append(random.randint(0, 50))

# make an ImageSquence in Neo
image_seq = ImageSequence(l, sampling_rate=500 * pq.Hz, spatial_scale="m", units="V")
image_seq = ImageSequence(l, sampling_rate=500 * neo.units.Hz, spatial_scale="m", units="V")


#################################################################
Expand Down
4 changes: 2 additions & 2 deletions examples/plot_with_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
ax2 = fig.add_subplot(2, 1, 2)
ax1.set_title(seg.file_origin)
ax1.set_ylabel("arbitrary units")
mint = 0 * pq.s
maxt = np.inf * pq.s
mint = 0 * neo.units.s
maxt = np.inf * neo.units.s
for i, asig in enumerate(seg.analogsignals):
times = asig.times.rescale("s").magnitude
asig = asig.magnitude
Expand Down
1 change: 1 addition & 0 deletions neo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@

from neo.core import *
from neo.io import *
import neo.units
4 changes: 2 additions & 2 deletions neo/io/asciiimageio.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class AsciiImageIO(BaseIO):

*Usage*:
>>> from neo import io
>>> import quantities as pq
>>> import neo.units
>>> r = io.AsciiImageIO(file_name='File_asciiimage_1.txt',nb_frame=511, nb_row=100,
... nb_column=100,units='mm', sampling_rate=1.0*pq.Hz,
... nb_column=100,units='mm', sampling_rate=1.0*neo.units.Hz,
... spatial_scale=1.0*pq.mm)
>>> block = r.read_block()
read block
Expand Down
4 changes: 2 additions & 2 deletions neo/io/elphyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
filled with other NEO structures:

>>> import numpy as np
>>> import quantities as pq
>>> a = AnalogSignal( signal=np.random.rand(300), t_start=42*pq.ms)
>>> import neo.units
>>> a = AnalogSignal( signal=np.random.rand(300), t_start=42*neo.units.ms)
>>> s.analogsignals.append( a )

and added to a newly created NEO Block:
Expand Down
10 changes: 5 additions & 5 deletions neo/io/neomatlabio.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,22 @@ class NeoMatlabIO(BaseIO):
This Python code generates the same block as in the previous scenario::

import neo
import quantities as pq
import neo.units
from scipy import rand, array

bl = neo.Block(name='my block with neo')
for s in range(3):
seg = neo.Segment(name='segment' + str(s))
bl.segments.append(seg)
for a in range(5):
anasig = neo.AnalogSignal(rand(100)*pq.mV, t_start=0*pq.s,
anasig = neo.AnalogSignal(rand(100)*neo.units.mV, t_start=0*neo.units.s,
sampling_rate=100*pq.Hz)
seg.analogsignals.append(anasig)
for t in range(7):
sptr = neo.SpikeTrain(rand(40)*pq.ms, t_start=0*pq.ms, t_stop=10*pq.ms)
sptr = neo.SpikeTrain(rand(40)*pq.ms, t_start=0*neo.units.ms, t_stop=10*neo.units.ms)
seg.spiketrains.append(sptr)
ev = neo.Event([0, 10, 30]*pq.ms, labels=array(['trig0', 'trig1', 'trig2']))
ep = neo.Epoch([10, 20]*pq.ms, durations=[4, 10]*pq.ms, labels=array(['a0', 'a1']))
ev = neo.Event([0, 10, 30]*neo.units.ms, labels=array(['trig0', 'trig1', 'trig2']))
ep = neo.Epoch([10, 20]*neo.units.ms, durations=[4, 10]*neo.units.ms, labels=array(['a0', 'a1']))
seg.events.append(ev)
seg.epochs.append(ep)

Expand Down
5 changes: 3 additions & 2 deletions neo/io/nestio.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ class NestIO(BaseIO):

Usage:
>>> from neo.io.nestio import NestIO
>>> import neo.units

>>> files = ['membrane_voltages-1261-0.dat',
'spikes-1258-0.gdf']
>>> r = NestIO(filenames=files)
>>> seg = r.read_segment(gid_list=[], t_start=400 * pq.ms,
t_stop=600 * pq.ms,
>>> seg = r.read_segment(gid_list=[], t_start=400 * neo.units.ms,
t_stop=600 * neo.units.ms,
id_column_gdf=0, time_column_gdf=1,
id_column_dat=0, time_column_dat=1,
value_columns_dat=2)
Expand Down
2 changes: 1 addition & 1 deletion neo/io/proxyobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class AnalogSignalProxy(BaseProxy):
block_index=0,
seg_index=0)
>>> anasig = proxy_anasig.load()
>>> slice_of_anasig = proxy_anasig.load(time_slice=(1.*pq.s, 2.*pq.s))
>>> slice_of_anasig = proxy_anasig.load(time_slice=(1.*neo.units.s, 2.*neo.units.s))
>>> some_channel_of_anasig = proxy_anasig.load(channel_indexes=[0,5,10])

"""
Expand Down
6 changes: 3 additions & 3 deletions neo/io/tiffio.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class TiffIO(BaseIO):

*Usage*:
>>> from neo import io
>>> import quantities as pq
>>> r = io.TiffIO("dir_tiff",spatial_scale=1.0*pq.mm, units='V',
... sampling_rate=1.0*pq.Hz)
>>> import neo.units
>>> r = io.TiffIO("dir_tiff",spatial_scale=1.0*neo.units.mm, units='V',
... sampling_rate=1.0*neo.units.Hz)
>>> block = r.read_block()
read block
creating segment
Expand Down
1 change: 1 addition & 0 deletions neo/units/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from quantities.units import *
Loading