Coder Social home page Coder Social logo

neurodata / brainlit Goto Github PK

View Code? Open in Web Editor NEW
26.0 26.0 17.0 1.97 GB

Method container for computational neuroscience on brains.

Home Page: http://brainlit.neurodata.io/

License: Other

Python 99.79% Shell 0.03% Dockerfile 0.18%
neuroimaging neuroscience python

brainlit's People

Contributors

af1111 avatar alishakodibagkar avatar bvarjavand avatar caseyweiner avatar dependabot[bot] avatar devincrowley avatar felixchihting avatar fxu10 avatar jacopoteneggi avatar johnduva avatar jtrieu2 avatar jwright707 avatar meikah-101 avatar mfigdore avatar mlemyco avatar pssf23 avatar ryanlu41 avatar sanika1201 avatar sejalsrivastava1 avatar shreyasingh1 avatar suki-o avatar tanchyking avatar tathey1 avatar vanniexu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

brainlit's Issues

Convert swc to networkx Graph and vice versa

Neuron traces are commonly stored in the SWC format. Networkx is a popular python library for manipulating graph data structures. It will be useful to have standardized methods to read in SWCs as networkx graphs and, similarly, to export networkx graphs as SWCs.

Update requirements.txt file

Currently the requirements.txt file in the root directory and the docs branch have not been updated to the most current version of brainlit and possibly contain unnecessary packages, causing minor slowdowns.

Test visualization code in `brainlit/viz`

Test:

  • swc.py (already done, just add tests for using read_s3 with other methods)
  • visualize.py (requires adapting the code)

Update notebooks for

  • swc.py

  • visualize.py

  • Build docs in sphinx

region viz method

write a somewhat optimized method (not a for loop) which:

  • takes: neuron_id, vertex_id, number_of_edges.
  • outputs: napari view of image with swc overlay including all vertices within number_of_edges edges from vertex_id.

NeuroglancerSession without segmentation

Currently a segmentation volume/url is required to interact with a NeuroglancerSession object, when it should be possible to interact without out (to view image layers).

  • default self.url_segments = None
  • raise ValueError if a method that uses segmentation layers is called when there is none
  • create setter method to assign class attribute

Add data validation script to utils

This would be a script that gets run on the cis server.

  • pulls random chunks of data from source octree /cis/local/jacs/...
  • pulls same chunks from cloud upload
  • verified chunks are identical

It would be a great QA script to instill confidence that uploads are valid.

code and test semi-automated segmentation

Tasks:
[Done] 1. Merge segmentation algorithm pipeline and tutorial notebook.
[Done] 2. Generate framework/pipeline tutorial to display automated segmentation into Napari, to enable easier manual segmentation ("semi-augmented" segmentation). Ensure manual segmentations can be uploaded to AWS via this protocol.
[Done] 3. Write documentation (and (if useful) a manuscript - (not doing this, sticking with documentation)) describing the process and pipeline for a user to fix errors with a paint tool and save a binary segmentation mask.
[Done] 4. Ensure algorithm can be run on consecutive points and the results be combined.

Submit pull request adding nonlinear features functionality

Submit a pull request to this repository which does the following things:

  • Develop a python script called brainlit/preprocessing/features/nonlinear_features.py which:
  1. pulls a region around a voxel
  2. computes activations of new nonlinear filters on the region
    • an MLP with sigmoid activation function, and softmax function on the last layer

These features would then be able to be used with a classifier (such as brainlit/algorithms/regression/log_regression.py) to predict axon vs not axon

  • Write tests for brainlit/preprocessing/features/nonlinear_features.py and document each method.

  • create a jupyter notebook in the documentation which demonstrates functionality visually and serves as a tutorial for other developers to trust and use the code

code and test running on separate brains

Tasks for this semester: Automate process of uploading raw octree data and pulling back as a neuroglancer precomputed format to be segmented.

  • Create temporary s3 bucket for storing precomputed data format.

  • Pull both image and fragment data in an octree format(most likely from a cis computer) and upload as both neuroglancer precomputed onto the s3 bucket.

  • Leverage code already in mouselight_code repo (swc2neuroglancer, upload_to_neuroglancer) for this task

  • Pull neuroglancer data from bucket to view and segment in napari.
    Final DoD is a script for processing raw swc, image data into ngl_pipeline.py for visualization

enable the features folder in brainlight/preprocessing

The features folder computes statistics on a volume to reduce dimensionality of the data our algorithms run on.
brainlit/preprocessing/linear_features.py converts a volume into a set of features based on different filter activations.
brainlit/preprocessing/neighborhood.py converts a volume into a set of features based on neighborhood-based algorithms.

Submit a Pull Request to the brainlit repository which makes the following changes:

  • modify linear_features.py to function on precomputed volumes using brainlit methods.

  • test linear_features.py to validate output - including jupyter notebook tutorials to verify visually.

  • write docstrings for each method in linear_features.py which allow others to easily use the methods.

  • modify neighborhood.py to function on precomputed volumes using brainlit methods.

  • test neighborhood.py to validate output - including jupyter notebook tutorials to verify visually.

  • write docstrings for each method in neighborhood.py which allow others to easily use the methods.

Overhaul brainlit unit tests

Due to changes in the core brainlit code, many tests were disabled.

Slowly working on uncommenting and moving tests out from the tests/archive folder will improve code coverage as functionality is restored.

Additionally, many old tests were not designed as true unit tests and stand to be improved.
I suggest taking a look at a general unit testing guide and a pytest-specific guide.

The tests to be revived include everything in tests/archive/:

  • test_adaptive_thresh.py
  • test_image_process.py
  • test_linear_features.py
  • test_log_regression.py
  • test_visualize.py
  • test_preprocess.py
  • test_subneighborhood.py

Code coverage can be tracked via https://codecov.io/gh/neurodata/brainlit

I imagine this will take multiple PRs

Incorporate Registration in the brainlit documentation

Brainlit uses sphinx-autodoc which makes documentation for the repo directly from method docstrings.

  • The registration folder needs to be added to the list of subpackages here
  • A file named registration.rst needs to be created in the same directly mimicking files like algs.rst such that
    • Each sub-subpackage (and so on) is included as a module
    • Each method and class from each module with appropriate docstrings is listed using .. autoapifunction:: and .. autoapiclass::, respectively.

Tutorial to replicate voxel classification results on brain1 data

Make a notebook to (approximately) replicate this poster.

In particular, I want to see a comparison between a logistic classifier that only looks at voxel intensity, and an MLP that looks at a 7x7x7 neighborhood. The task is to classify class 0 (background) vs class 1 (foreground).

You can generate training data by using tube_seg on the swc points to identify examples of foreground, and you can brainstorm your own way to identify examples of background.

The final comparison should be ROC curves on some test data.

[ndd] add Windows OS support

The current introductory tutorial notebook does not work on Windows OS, likely because of path issues in the dependency, CloudVolume. First, can someone else replicate this issue? Can we update CloudVolume for find a work around?

Sanitize inputs for all scripts

This means

  • the scripts all raise warnings or errors depending on the inputs
  • the tests for each script assert each warning or error is raised when it should, and not raised when it shouldn't

Currently this issue is focused on:

  • brainlit/utils/ngl_pipeline.py
  • brainlit/utils/swc.py
  • brainlit/utils/upload.py
  • brainlit/utils/util.py

State of the art neuron segmentation algs

There are several previously published neuron segmentation algorithms, we will be comparing our methods to those at some point, does anyone want to get started implementing them?

Access github secret containing AWS private key when running .aws.sh

Or, find an alternative way to give collaborators read access to an s3 bucket with brain data.

Or, allow the case that each collaborator should manually request the private key.

Or, expose the private key allowing anyone to pull data from our s3 bucket (probably not this one).

Allow upload_volumes to start from a specfic mip/chunk_idx

CloudVolume will sometimes hang randomly, interrupting large uploads.

Currently, if an error happens, we only print a short error message, and the upload must be restarted from scratch.

It would be far superior to print the mip and chunk the error was on along with the error, enabling continuation of a large, multi-day upload.

The previous data upload looked like the following, using code from the old-upload branch.

Screen Shot 2020-08-07 at 12 58 11 PM

Current progress to make this feature usable to any user is in the continue_upload branch.
Specifically,

Adding tests and debugging still needs to be done. Tests would be added in tests/test_upload.py, adding the continue_upload parameter to the type checking test for upload_volumes, as well as adding a test exclusively checking validity of continuing uploads from the middle and end indices.

brainlit repo too large

The test files make development via docker slow.

Solution is to move test files to a separate testing branch and leave master clean (at most, just the lowest resolution image).

Convert .swc file to .mat file, and randomly merge neurons

While neuron traces are often stored in the .swc format, there are certain limitations to neuron structure within .swc files. A feature is needed to convert .swc files to .mat files, which store neurons as vertex and edge lists.

Additionally, the feature should allow for the merging of multiple individual neurons by creating random edges between two neurons - this will be used to evaluate the performance of G-Cut, a program from the following paper designed to segment individual neurons from neuron clusters: https://www.nature.com/articles/s41467-019-09515-0

regression code PR

  • clean up brainlit/algorithms/regression/log_regression.py
    maybe add a script to unflatten neighborhoods and pull a smaller chunk (in screenshot I sent you)
  • clean up tests/test_log_regression.py
    make sure you are asserting something meaningful about the results

good luck!

s3 credentials in .aws.sh are invalid

How to replicate:

delete .cloudvolume from the home directory and run .aws.sh

run docs/utils/downloading_brains.ipynb

And you get a SignatureDoesNotMatch error when creating a cloudvolume object with an s3 url.

Improve type checking via typeguard

As the repo is refactored (see the Reformatting project), pep484 type hints are being added (example here).

Typeguard allows for type checking via pep484 type hints, and using them would streamline the codebase and reduce some clutter.

Doing this instead of multiple lines of check_type(<input>, <type>) is far cleaner.

Lines to be changed include every type-checking line after a method (for example, upload.py lines 48-51). You can identify the line if it begins with check_.
Scripts with type hints and checking so far include:

small octree test data

  • pull a small amount of octree data (only the lowest 4 resolutions?) for testing
    put it into a data folder in the root project directory
  • write tests for tommy's code using this test data

Cylinder Segmentation

Implement a segmentation algorithm that takes a swc file as input. Create a binary mask of cylinders of a specified radius to connect the appropriate vertices of the swc.

Test and document these functions.

Improve utils tests

Similar to test_upload.py, using type checking and much more thorough validation.

  • test_session.py
  • test_swc.py

create official v0.0.1 of brainlit with basic functions

Basic functionality (tested with documentation)

  • create, load, and save data from and to s3 buckets
  • pipeline for manual annotations
  • basic neuron segmentation algorithms
  • train/test/validate neuron segmentation algorithms on data

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.