Giter VIP home page Giter VIP logo

pypreclin's Introduction

Python35

Description

pypreclin is a Python project that provides a collection of Python scripts for preprocessing MRI preclinical datasets. This work is made available by a community of people, amoung which the CEA Neurospin UNATI and CEA NeuroSpin UNICOG laboratories, in particular A. Grigis, J. Tasserie, and B. Jarraya.

Dependencies

The required Python dependencies to use the software are:

  • numpy
  • scipy
  • hopla
  • pyconnectome
  • pyconnectomist
  • nipype
  • matplotlib
  • nibabel
  • joblib
  • transforms3d
  • filelock
  • python-pypipe (optional)

This package requires also other softwares:

Install

Make sure you have installed all the dependencies listed above properly. Further instructions are available at http://neurospin.github.io/pypreclin/generated/installation.html

Example: we assume that in your current working directory you have a functional data 'func.nii', a structural data 'anat.nii' and a template 'mni-resampled_1by1by1.nii'.

sudo apt install fsl-5.0-complete ants virtualenv -y
sudo ln -s /usr/lib/ants/N4BiasFieldCorrection /usr/bin
wget https://www.nitrc.org/frs/download.php/7446/jip-Linux-x86_64.tar.gz
tar xvzf jip-Linux-x86_64.tar.gz
rm jip-Linux-x86_64.tar.gz
virtualenv -p /usr/bin/python3.5 ./env
. env/bin/activate
pip install --no-cache-dir pypreclin
python env/bin/pypreclin_preproc_fmri -h
mkdir outputs
python env/bin/pypreclin_preproc_fmri \
        -f func.nii \
        -a anat.nii \
        -s test \
        -o outputs \
        -r 2.4 \
        -t mni-resampled_1by1by1.nii \
        -j jip-Linux-x86_64/bin \
        -NA RIA \
        -NF RIA \
        -C /etc/fsl/fsl.sh

Using Singularity

Singularity (https://singularity.lbl.gov/) is convenient to deploy complete pypreclin installations (including all dependencies). Once deployed, it is an isolated environment with separate filesystem and namespaces for processes, etc. Please refer to the Singularity documentation for more details.

We provide a Singularity image with pypreclin, which can be found at http://biodev.cea.fr/pypreclin/pypreclin-ubuntu.simg.

To use it install first Singularity. On Debian/Ubuntu the package is called singularity-container. You can check that Singularity is installed by typing singularity --help in a terminal.

Example: we assume that in the '/volatile/pypreclin' direcctory you have a functional data 'func.nii', a structural data 'anat.nii' and a template 'mni-resampled_1by1by1.nii'.

Warning: no X11, you need to provide the align.com files.

wget http://biodev.cea.fr/pypreclin/pypreclin-ubuntu.simg
mkdir /volatile/pypreclin/outputs
sudo apt install singularity-container
sudo nano /etc/singularity/singularity.conf
        mount home = no
singularity run --cleanenv --bind /volatile/pypreclin pypreclin-ubuntu.simg \
    -V 2 \
    -o /volatile/pypreclin/outputs \
    -s test \
    -f /volatile/pypreclin/func.nii \
    -a /volatile/pypreclin/anat.nii \
    -r 2.40 \
    -t /volatile/pypreclin/mni-resampled_1by1by1.nii \
    -NA RIA \
    -NF RIA \
    -N normalize/align.com \
    -M coreg/align.com \
    -C /etc/fsl/5.0/fsl.sh \
    -j /i2bm/local/jip-Linux-x86_64/bin

pypreclin's People

Contributors

agrigis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

pypreclin's Issues

Testing pypreclin at NIN

Hi people,

Congrats on getting the pipeline out and thanks for making it all open. I am interested in comparing the results against our/my own preprocessing pipeline (https://github.com/VisionandCognition/NHP-BIDS) to see if it would make sense to change our workflow. I'll be trying some things in the upcoming days/weeks depending on available time and will report back here with anything that's unclear, won't work or required extra tweaking.

To start things off:

  • there's a typo in the very first 'functional' line of your example preproc.py (and the notebook too). It tries to import prepoc instead of preproc, which of course doesn't work. It took me a while to not misread it as it should be and realize the 'r' was missing.
  • os is not imported, but it is used
  • the way the example is set up, warp may be set to False, but the arguments to do unwarping are still required by preproc yielding the following error: TypeError: preproc() missing 8 required positional arguments: 'delta_te', 'dwell_time', 'manufacturer', 'blip_files', 'blip_enc_dirs', 'unwarp_direction', 'phase_file', and 'magnitude_file'. I now initialize these arguments as None, but if unwarping is optional these arguments should probably be made obstional in pypreclin as well.
  • jipdir is first specified, then overwritten with a hardcoded path (/jip/bin)

The code then references an fslconfig python environment that doesn't exist on my system. ($FSLDIR is of course an existing environment variable, but that's not enough).

So, it currently doesn't seem incredibly straightforward to run pypreclin on another system. Perhaps I should look at the singularity image. I haven't used singularity before, but I installed it and figured out how to get into a shell on the image and link some data-folders. If I go to a python3 shell on the singularity image I can import the pypreclin module but if I then want to configure the paths to run preproc I don't know where I should find the jip folder. Your example lists /jip/bin but this doesn't exist. Nor do /etc/jip, /opt/jip, or /bin/jip. For now this is also a dead end...

Are there any superobvious things I'm missing? Have you tested running pypreclin outside of Neurospin or on a 'virgin' system?

Issue with the coordinate

Hello,

I'm trying to use pypreclin singularity to do preprocessing of data, and here is my test data

  1. Macaque_F99_LR_brian_1p5.nii (template, RAS)
  2. Kk_T1_brain_highRes_reorigin.nii (subject T1, IAL)
  3. Task.nii.gz (subject task)
    Singularity code used are as follows:

singularity run '/home/sangtian/ST_floder/tmp/pypreclin_test/pypreclin-ubuntu.simg' -V 2 -o 'test_out' -s test -f 'task.nii.gz' -a 'kk_T1_brain_highRes_reorigin.nii.gz' -r 2 -t 'Macaque_F99_LR_brain_1p5.nii' -NA RAS -NF RAS -C /etc/fsl/5.0/fsl.sh -j /i2bm/local/jip-Linux-x86_64/bin

When the program executes to Normalise, an error occurs as:
“Source file 'kk_T1_brain_highRes_reorigin.nii.gz' (LAS) and taget file 'Macaque_F99_LR_brain_1p5.nii' (RAS) must have the same orientation for JIP to work properly.”

I checked the output of code, it had already done Slice timing, reorient, Realign, but empty in the folder Normalization

So then I check the coordinate of subject T1 and template in FSLeyes, the coordinate of subject T1 is original as IAL, and the template is RAS. Then I try to change the coordinate of subject T1 from IAL to RAS, I used the function reorient_image and check_orientation from \pypreclin-master\pypreclin\utils\reorient.py

But even after the preprocessing, the orientation of subject T1 is still IAL, I am confused about it and I am using the following code:

`

from reorient import reorient_image, check_orientation

data_path = '../pypreclin_data/'
T1_data = data_path + 'kk_T1_brain_highRes_reorigin.nii'
RAS_T1_data = data_path + 'RAS_kk_T1_brain_highRes_reorigin.nii.gz'

reorient_image(T1_data, 'RAS', 'RAS_', data_path)
print(check_orientation([T1_data, RAS_T1_data]))

`

the output of the code is: (True, ['IAL', 'IAL'])

From the output, the reorient_image function does not change the coordinate of subject T1, and I don't know what the problem is.

I have also used other packages to orientate the coordinates, e.g. fslreorient2std, fslorient, fslswapdim, and I can convert the coordinates to "LAS" but never to RAS!

At this point, I thought, orient such a process seems to be easily integrated in the singularity step, it seems unnecessary to let us operate separately, so I checked the output folder, and I did find that there was an orient folder in the second step, so I assumed that the container had already completed the reorientation step

But I checked the coordinate of the output file named ‘dRAS_kk_T1_brain_highRes_reorigin.nii.gz’ generated by singularity is still ‘LAS’, so I am really confused about the result, I can't use Pypreclin and FSL's toolkit to solve this coordinate, and also the problem seems to be unsuccessfully handled by the official container, So I really don't know what to do with what's happening right now.

What exactly should I do to keep singularity's program running?

Issue with pyconnectome

Hello,

I am trying to get Pypreclin up and running in our lab. I am trying just to run the example code on one of my functional and anatomical scans, as a first step (before adding fieldmap distortion correction). The pipeline is getting stuck after getting through most of step 5 (normalization) and throwing an error that traces back to pyconnectome. See the attached screen shot of the error messages. I do have the proper versions of python and all of the other dependencies installed. Do you have any insight? Thanks,

Erin
Errorpypreclin

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.