Giter Club home page Giter Club logo

neurphys's Introduction

Neurphys

Neurphys (pronounced "nervous") is an IO and analysis package built to streamline and standardize the data handling, analysis, and visualization of electrophysiology and calcium imaging data.

Dependencies

Installation

First, download Anaconda which will come with most required libraries including numpy, pandas, scipy. Then download or clone the repository using git as follows,

$ git clone https://github.com/surmeierlab/neurphys

You can download dependencies which we provide in requirements.txt. Use pip to install the rest of dependencies i.e.

$ pip install -r requirements.txt

Install neurphys using setup.py as follows

$ python setup.py develop install

Usage

import neurphys as nu

Check out the tutorials page for jupyter notebooks showing specific use cases.

neurphys's People

Contributors

chadestep avatar dgalt avatar

Stargazers

Jeremy Atherton avatar Titipat Achakulvisut avatar  avatar

Watchers

James Cloos avatar  avatar

neurphys's Issues

new version of neo (?) breaks read_abf

I think the issue is with neo, as that's what makes the most sense. Just updated everything (conda, anaconda, neo), and am getting this exception:

Exception                                 Traceback (most recent call last)
<ipython-input-3-7e6a005709a2> in <module>()
      1 filepath = r'E:\Users\Dan\Desktop\17111016.abf'
----> 2 df = read_abf(filepath)
      3 plot_all(df)

C:\Anaconda3\lib\site-packages\neurphys-0.0-py3.5.egg\neurphys\read_abf.py in read_abf(filepath)
     45         time = seg.analogsignals[0].times - seg.analogsignals[0].times[0]
     46         data_dict['time'] = time
---> 47         df = pd.DataFrame(data_dict)
     48         df_list.append(df)
     49         sweep_list.append('sweep' + str(seg_num + 1).zfill(3))

C:\Anaconda3\lib\site-packages\pandas\core\frame.py in __init__(self, data, index, columns, dtype, copy)
    225                                  dtype=dtype, copy=copy)
    226         elif isinstance(data, dict):
--> 227             mgr = self._init_dict(data, index, columns, dtype=dtype)
    228         elif isinstance(data, ma.MaskedArray):
    229             import numpy.ma.mrecords as mrecords

C:\Anaconda3\lib\site-packages\pandas\core\frame.py in _init_dict(self, data, index, columns, dtype)
    360 
    361         return _arrays_to_mgr(arrays, data_names, index, columns,
--> 362                               dtype=dtype)
    363 
    364     def _init_ndarray(self, values, index, columns, dtype=None,

C:\Anaconda3\lib\site-packages\pandas\core\frame.py in _arrays_to_mgr(arrays, arr_names, index, columns, dtype)
   5095 
   5096     # don't force copy because getting jammed in an ndarray anyway
-> 5097     arrays = _homogenize(arrays, index, dtype)
   5098 
   5099     # from BlockManager perspective

C:\Anaconda3\lib\site-packages\pandas\core\frame.py in _homogenize(data, index, dtype)
   5409                 v = lib.fast_multiget(v, oindex.values, default=NA)
   5410             v = _sanitize_array(v, index, dtype=dtype, copy=False,
-> 5411                                 raise_cast_failure=False)
   5412 
   5413         homogenized.append(v)

C:\Anaconda3\lib\site-packages\pandas\core\series.py in _sanitize_array(data, index, dtype, copy, raise_cast_failure)
   2838     elif subarr.ndim > 1:
   2839         if isinstance(data, np.ndarray):
-> 2840             raise Exception('Data must be 1-dimensional')
   2841         else:
   2842             subarr = _asarray_tuplesafe(data, dtype=dtype)

Exception: Data must be 1-dimensional 

Started digging in to read_abf and what I'm thinking is that there is now a lot more information in something one of the things neo returns when it reads the abf file. Coming to this conclusion based on the data_dict that is passed to pd.DataFrame(data_dict) looks something like this:

{'channel_1': AnalogSignal with 1 channels of length 2000; units V; datatype float32 name: "b'IN3'" annotations: {'channel_index': 3} sampling rate: 20000.0 Hz time: 0.0 s to 0.1 s, 'primary': AnalogSignal with 1 channels of length 2000; units V; datatype float32 name: "b'IN2'" annotations: {'channel_index': 2} sampling rate: 20000.0 Hz time: 0.0 s to 0.1 s, 'time': array([ 0.00000000e+00, 5.00000000e-05, 1.00000000e-04, ..., 9.98500000e-02, 9.99000000e-02, 9.99500000e-02]) * s}

which obviously is a bit of a mess and pd.DataFrame can't handle.

Documentation

I need to properly document my new additions. This is mainly a reminder for me to do this after I'm finished writing up all the other junk I have to do to graduate.

naming conventions and not being able to access submodules

I'm not sure when this was changed, but when just doing import neurphys you have access to a number of the functions in the submodules. the problem is that a number of these functions have the same name as the submodules.

for example, if you go from neurphys import nuplot you're getting the function nuplot from the nuplot module, which is not what I was expecting. Rather I was hoping to import the nuplot module, from which i'd then be able to call functions such as nuplot or nu_genheatmap

same thing with read_abf.

normally what I do is import just the specific submodules that I need and will the call the functions associated with those modules (e.g. import neurphys.read_pv as rpv and then use rpv.import_folder)

If we're going to have, upon importing neurphys, it import a number of the functions contained in the submodules then we need to make sure that they're not named the same thing so that if someone wants to just import a particular module without importing everything else they can still do that

pandas .ix method

Considering it looks like this will be depreciated at some point in the near(ish) future, I suggest replacing it with an indexing method that will be around for a while (maybe .xs?).

Nuplot wish list

Couple things it would be nice to have in nuplot

  1. Make clean_axis more generally useful by making the units argument optional. A lot of time I draw my own scale bars, so I don't need clean_axis to do it.

  2. For nu_raster provide the option to change the height of the raster bars.

  3. Give nu_raster option of using clean_axis. This one is maybe less necessary if 1 is implemented (although 1 would need to implemented to get this to work anyway).

I might get around to doing these in the next day or two since I've implemented them already in my own stuff, just wanted to open discussion first to get thoughts on changes.

Add docs directory

Need to add a docs directory and fill it with useful documents to aide in creating extensions of the package. I suggest modeling it after NumPy

Future proofing

At some point, there will be a decent overhaul of Pandas (https://wesm.github.io/pandas2-design/index.html).

We should prevent the problems we can by keeping track of anticipated API changes and depreciated functions/methods and fix them before it becomes a problem.

And honestly, it couldn't hurt to go through the code base and do some clean up while the library is still young. Just a thought.

utilities import in synaptics.py

I keep getting an import issue specifically from this module when importing neurphys. The notebook spits out an error that it "can't find utilities," even though two other modules import the utilities module the exact same way.

I temporarily got around this by commenting out the synaptics import in the init.py until we find a fix.

Exporting figures

Matplotlib 2.0 depreciated the specification of backends in stylesheets. This means for figures to render correctly for lab personnel the 'pdf' backend needs to be explicitly set, otherwise you'll probably run into plenty of issues with saved figures.

Modify __init__.py?

This may be an open issue for a while, but we should seriously think about it for the sake of tab-completion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.