Skip to main content

Python package for segmentation of axons and morphological analysis.

Project description

Build Status codecov License: MIT PyPI version

Autoballs logo

Pipeline for analysis of ex vivo explants

Installation

While writing this package I tried my best not to reinvent the wheel for that reason there are a number of dependencies on Fiji. When installing the package please ensure that you create a conda env with relatvent openjdk8 and Maven. Furthermore, due to constant updates of Fuji please use get_fiji_version.sh script to download the working version.

git clone git@github.com:rg314/autoballs.git

Go into the autoballs firectory get the working Fiji version

source scripts/get_fiji_version.sh 

Create conda env

conda create -n autoballs python=3.8

Install autoballs in editable mode

pip install -e .

For training you might need to install pytorch CUDA otherwise for general useage segmentation will be fine on CPU. However, for CUDA run

conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch

or for the latest version check out PyTorch PyTorch

File structure

Please note you will need to follow the following file conventions for this to work properly. I’ve not yet included the AFM section but I’m planning on adding this part in as well so there will be a later dependency.

├── 20210226 Cam Franze
│   ├── afm
│   │   ├── data
│   │   │   ├── e01_nt_fg1_1force-save-2021.02.27-11.46.03.003.jpk-force
│   │   │   ├── ...
│   │   │   └── ve1_fg1_1force-save-2021.02.27-11.34.31.418.jpk-force
│   │   ├── datatxt
│   │   │   ├── e01_nt_fg1_1force-save-2021.02.27-11.46.03.003.txt
│   │   │   ├── ...
│   │   │   └── ve1_fg1_1force-save-2021.02.27-11.34.31.418.txt
│   │   └── run.py
│   ├── e01_nt_fg1_1
│   │   └── series.nd2
│   ├── e01_nt_fg2_1
│   │   └── series.nd2
│   └── metadata.txt

Metadata

You will need to have a metadata file that store info about the frogs and gels for example

{
'gel': 
{
'e01':'Elastic 100 Pa',
'e1':'Elastic 1 kPa',
've1':'Viscoelastic 1 kPa',
'glass':'Glass',
},
'frog': 
{
'fg1':'Upstairs outside box 176b 13:30 17/20',
'fg2':'Downstairs inside box 176b 13:30 17/20',
'fg3':'Downstairs outside box 182b 13:30 17/20',
'fg4':'Upstairs inside box 176b 13:30 17/20',
}
}

Note the subfolders need to have the same naming convention i.e. if e01_nt_fg1_1 is processed the frog and gel metadata will be identified as

  1. Upstairs outside box 176b 13:30 17/20
  2. Elastic 100 Pa

Usage

Check that the config is set-up correctly in scripts/pipeline_cnn.py

You'll need to ensure that the path is pointing to the correct folder where each subdir has the file structure outlined above.

def config():
    configs = dict()

    if sys.platform == "linux" or sys.platform == "linux2":
        path = '/media/ryan/9684408684406AB7/Users/ryan/Google Drive/TFM Cambridge/2021/Frogs'
    elif sys.platform == "win32":
        path = 'C:\\Users\\ryan\\Google Drive\\TFM Cambridge\\2021\\Frogs'
    elif sys.platform == 'darwin':
        path = '/Users/ryan/Google Drive/TFM Cambridge/2021/Frogs'


    configs['path'] = path
    configs['sample'] = '20210305 Cam Franze' #'20210226 Cam Franze'
    configs['metadata_file'] = f"{configs['path']}/{configs['sample']}{os.sep}metadata.txt"
    configs['metadata'] = biometa(configs['metadata_file'])
    configs['frog_metadata'] = configs['metadata']['frog']
    configs['gel_metadata'] = configs['metadata']['gel']
    configs['sholl'] = True
    configs['create_results'] = True
    configs['results_path'] = 'results' + os.sep + configs['sample'] + '_results'
    configs['seg'] = True
    configs['headless'] = True
    configs['step_size'] = 5
    configs['device'] = 'cuda'
    configs['best_model'] = './best_model_1.pth'

If you have all path envs and file structures set up correctly you can run the pipeline as

python scripts/pipeline_cnn.py

A resuls folder will created and stats will be performed on the sample i.e.

(autoballs) ryan@ryan:~/Documents/GitHub/autoballs$ python scripts/pipeline_cnn.py 
           Multiple Comparison of Means - Tukey HSD, FWER=0.05            
==========================================================================
    group1           group2       meandiff p-adj   lower    upper   reject
--------------------------------------------------------------------------
 Elastic 1 kPa     Elastic 100 Pa -43.0119 0.0031 -74.6687 -11.3551   True
 Elastic 1 kPa              Glass -15.4829 0.4857 -43.6976  12.7318  False
 Elastic 1 kPa Viscoelastic 1 kPa -17.8286 0.7525 -66.5802  30.9231  False
Elastic 100 Pa              Glass   27.529 0.0466   0.2912  54.7668   True
Elastic 100 Pa Viscoelastic 1 kPa  25.1833 0.5246 -23.0095  73.3762  False
         Glass Viscoelastic 1 kPa  -2.3457    0.9 -48.3508  43.6594  False
--------------------------------------------------------------------------
           Multiple Comparison of Means - Tukey HSD, FWER=0.05            
==========================================================================
    group1           group2       meandiff p-adj   lower    upper   reject
--------------------------------------------------------------------------
 Elastic 1 kPa     Elastic 100 Pa -43.0119 0.0031 -74.6687 -11.3551   True
 Elastic 1 kPa              Glass -15.4829 0.4857 -43.6976  12.7318  False
 Elastic 1 kPa Viscoelastic 1 kPa -17.8286 0.7525 -66.5802  30.9231  False
Elastic 100 Pa              Glass   27.529 0.0466   0.2912  54.7668   True
Elastic 100 Pa Viscoelastic 1 kPa  25.1833 0.5246 -23.0095  73.3762  False
         Glass Viscoelastic 1 kPa  -2.3457    0.9 -48.3508  43.6594  False
--------------------------------------------------------------------------

drawing

Example

image

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autoballs-0.0.2.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

autoballs-0.0.2-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file autoballs-0.0.2.tar.gz.

File metadata

  • Download URL: autoballs-0.0.2.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.3

File hashes

Hashes for autoballs-0.0.2.tar.gz
Algorithm Hash digest
SHA256 d69a3d90db4cf6023db39d14dbfd6392e32f76069e0ce79bf2e273bfc4c1c784
MD5 299fae5adaf4022650dd0052d1786d12
BLAKE2b-256 7964cd3aa22ebe5fe771a6f545358dd383ca686670aa505e78dd7bbff2e7732a

See more details on using hashes here.

File details

Details for the file autoballs-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: autoballs-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.3

File hashes

Hashes for autoballs-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cba659b68ccba70de4d28b124e3d1b664ea2fb9a3eaed0036a40d40bcae2df95
MD5 5957ef96bd5282af11df9649d87e2a8a
BLAKE2b-256 00b53fc3b00fe9132eda2789e55619ca9d9dad93e562d411c215fe504eb97efd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page