Giter Site home page Giter Site logo

niftyreg_loop_bash's Introduction

NiftyReg_Loop_Bash

Running NiftyReg in for-loop in MacOS/Unix environment using BASH script.

Download NiftyReg

NiftyReg 1.3.9 (as of May 2016) https://sourceforge.net/projects/niftyreg/

Install NiftyReg

http://sourceforge.mirrorservice.org/n/ni/niftyreg/install_NiftyReg_macLinux.pdf

Overall, the instruction is fairly accurate. Except, the project will be installed into 'build' folder but not into 'install' folder as it mentioned by the instruction. Based on my experience, CMAKE 2.8.5 worked on both OSX9 (with Xcode6) and OSX11 (with Xcode7). (CMAKE 2.8.5 is GUI based. Xcode may or may not be required.) After 'generate', '$make' and '$make install' will be excuted in Terminal/Command Window. The newer version of CMAKE (such as 3.2) did not work.

I did not do the following part. But it is working.

            NIFTYREG_INSTALL=<path_to_your_niftyreg_install> (/Users/XYXY/niftyreg_install in the current example)
            export PATH=${PATH}:/${NIFTYREG_INSTALL}/bin
            export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${NIFTYREG_INSTALL}/lib

CMAKE version 2.8 https://cmake.org/files/v2.8/

Another instruction

http://cmictig.cs.ucl.ac.uk/wiki/index.php/NiftyReg_install

My favorite work flow using MATLAB

            Image file -> MATLAB file -> Nifty file -> NiftyReg -> Nifty file -> MATLAB file

NIfTI_20140122 (as of May 2016): Nifty Image Tool on MATLAB

http://www.mathworks.com/matlabcentral/fileexchange/8797-tools-for-nifti-and-analyze-image

by Jimmy Shen

23 Oct 2005 (Updated 22 Jan 2014)

http://www.mathworks.com/matlabcentral/profile/authors/757722-jimmy-shen

  1. MATLAB to Nii (2D)

    %% Input %%

    % IM: image data

    % filename: file name

    % Ref: reference/target image data

    % Mask: Mask data on reference/target image

    save_nii(IM, [filename '.nii']) % IM.nii

    save_nii(Ref, 'Ref.nii') $Ref.nii

    imagesc(Ref);

    [Mask, x_ref_mask, y_ref_mask] = roipoly;

    save_nii(Mask, 'Mask.nii') $Mask.nii

  2. Nii to MATLAB (Stack of 2D images)

    %% Input %%

    % i1: image ID number

    % x_ref, y_ref: points[x,y] on the reference image

    % Deformed Coordinate System: IM_def.nii

    % Warped Image: IM_warped.nii

    %% Deformed Coordinate System %%

    Def_nii = load_nii('IM_def.nii');

    Y_def = Def_nii.img(:,:,1,1,1);

    X_def = Def_nii.img(:,:,1,1,2);

    %% Reference Coordinate System %%

    [X_ref,Y_ref] = meshgrid([1:size(X_def,2)], [1:size(X_def,1)]);

    %% Point by Point Transformation %%

    x_def(:,i1) = interp2(X_ref,Y_ref,X_def,x_ref,y_ref);

    y_def(:,i1) = interp2(X_ref,Y_ref,Y_def,x_ref,y_ref);

    %% Warped Image %%

    Warped_nii = load_nii('IM_warped.nii');

    Warped_IM = Warped_nii.img;

Use NiftyReg_Loop.sh

There are XXX source/moving 2D images to be registered onto the reference/target 2D image around the specific area specified by a mask.

%% Modify the number of loops using text editor %%

e.g. 1 to 721

              for NUM in `seq 1 1 721`

%% Run NiftyReg_Loop.sh in Terminal/Command Window

              bash NiftyReg_Loop.sh

%% Input files (in the same folder) %%

Target Image: Ref0001.nii

Source Images: IM0001.nii to IM0XXX.nii

Mark: Mask0001.nii (0 and 1 on Ref0001.nii)

%% Output files %%

Affine Transformation: IM0XXX_aff.txt. Quick and dirty affine transformation (principal stretch, translation, shear, and rotation) with no deformable local control.

Warped Images: IM0XXX_warped.nii. Warped source images; Target Image ~ Warped Image (Hopefully)

Deformed Coordinate System: IM0XXX_def.nii

CPP file: IM0XXX_cpp.nii

About NiftyReg

Personally, my favorite deformable image registration software developed by a group of scientists at University College London, United Kingdom.

https://sourceforge.net/projects/niftyreg/

Reference


LICENSE

Copyright (c) 2009, University College London, United-Kingdom. All rights reserved.


CONTACT

For any comment, please, feel free to contact Marc Modat ([email protected]). https://sourceforge.net/p/niftyreg/git/ci/master/tree/

  May 29th 2016
      Tatsuya J. Arai 

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.