### Basic Registration Setup Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.ants.registration.md This example demonstrates the basic setup for the ANTs Registration interface, specifying fixed and moving images, output transform prefix, initial transform, and the types of transforms to be used (Affine and SyN). It also shows how to configure parameters like number of iterations, metric, sampling strategy, and convergence criteria for each stage. ```APIDOC ## antsRegistration ### Description Sets up and executes the ANTs registration process. This interface allows for configuring various aspects of the registration, including image inputs, transform types, optimization parameters, and output options. ### Method This is an SDK interface, not an HTTP endpoint. ### Parameters - **fixed_image** (string) - Path to the fixed image. - **moving_image** (string) - Path to the moving image. - **output_transform_prefix** (string) - Prefix for the output transform files. - **initial_moving_transform** (string) - Path to an initial transform to apply to the moving image. - **transforms** (list of strings) - List of transform types to use (e.g., 'Affine', 'SyN'). - **transform_parameters** (list of tuples) - Parameters specific to each transform type. - **number_of_iterations** (list of lists of ints) - Number of iterations for each stage of the registration. - **dimension** (int) - Dimensionality of the images (e.g., 3 for 3D). - **write_composite_transform** (boolean) - Whether to write a composite transform file. - **collapse_output_transforms** (boolean) - Whether to collapse all output transforms into a single file. - **initialize_transforms_per_stage** (boolean) - Whether to initialize transforms for each stage independently. - **metric** (list of strings) - The similarity metric to use for registration (e.g., 'Mattes'). - **metric_weight** (list of floats) - Weight for each metric. - **radius_or_number_of_bins** (list of ints) - Radius for Mean Squares or number of bins for Mattes metric. - **sampling_strategy** (list of strings or None) - Strategy for sampling image data (e.g., 'Random'). - **sampling_percentage** (list of floats or None) - Percentage of data to sample. - **convergence_threshold** (list of floats) - Convergence threshold for each stage. - **convergence_window_size** (list of ints) - Window size for convergence checking. - **smoothing_sigmas** (list of lists of floats) - Smoothing sigmas for images in voxels. - **sigma_units** (list of strings) - Units for smoothing sigmas ('vox' or 'mm'). - **shrink_factors** (list of lists of ints) - Shrink factors for downsampling images during registration. - **use_estimate_learning_rate_once** (list of booleans) - Whether to estimate the learning rate once per stage. - **use_histogram_matching** (list of booleans) - Whether to use histogram matching. - **output_warped_image** (string) - Path for the output warped image. - **invert_initial_moving_transform** (boolean) - Whether to invert the initial moving transform. - **winsorize_lower_quantile** (float) - Lower quantile for winsorizing image intensities. - **winsorize_upper_quantile** (float) - Upper quantile for winsorizing image intensities. ### Request Example ```python import copy, pprint from nipype.interfaces.ants import Registration reg = Registration() reg.inputs.fixed_image = 'fixed1.nii' reg.inputs.moving_image = 'moving1.nii' reg.inputs.output_transform_prefix = "output_" reg.inputs.initial_moving_transform = 'trans.mat' reg.inputs.transforms = ['Affine', 'SyN'] reg.inputs.transform_parameters = [(2.0,), (0.25, 3.0, 0.0)] reg.inputs.number_of_iterations = [[1500, 200], [100, 50, 30]] reg.inputs.dimension = 3 reg.inputs.write_composite_transform = True reg.inputs.collapse_output_transforms = False reg.inputs.initialize_transforms_per_stage = False reg.inputs.metric = ['Mattes']*2 reg.inputs.metric_weight = [1]*2 reg.inputs.radius_or_number_of_bins = [32]*2 reg.inputs.sampling_strategy = ['Random', None] reg.inputs.sampling_percentage = [0.05, None] reg.inputs.convergence_threshold = [1.e-8, 1.e-9] reg.inputs.convergence_window_size = [20]*2 reg.inputs.smoothing_sigmas = [[1,0], [2,1,0]] reg.inputs.sigma_units = ['vox'] * 2 reg.inputs.shrink_factors = [[2,1], [3,2,1]] reg.inputs.use_estimate_learning_rate_once = [True, True] reg.inputs.use_histogram_matching = [True, True] reg.inputs.output_warped_image = 'output_warped_image.nii.gz' print(reg.cmdline) ``` ### Response This interface executes a command-line tool. The response is the output of the command, typically including status messages and generated file paths. ``` -------------------------------- ### Basic Registration Setup Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.ants.md This example demonstrates a basic setup for image registration using the ANTS Registration interface. It specifies fixed and moving images, output transform prefix, initial transform, and the types of transforms to be used. ```APIDOC ## Registration Interface Example ### Description This example shows how to initialize and configure the ANTS Registration interface for a typical image registration task. ### Method `Registration()` ### Parameters - `fixed_image` (string) - Path to the fixed image. - `moving_image` (string) - Path to the moving image. - `output_transform_prefix` (string) - Prefix for the output transform files. - `initial_moving_transform` (string) - Path to an initial transform to apply. - `transforms` (list of strings) - List of transform types to use (e.g., 'Affine', 'SyN'). - `transform_parameters` (list of tuples) - Parameters for each transform. - `number_of_iterations` (list of lists of integers) - Number of iterations for each stage of each transform. - `dimension` (integer) - Dimensionality of the images (e.g., 3 for 3D). - `write_composite_transform` (boolean) - Whether to write a composite transform file. - `collapse_output_transforms` (boolean) - Whether to collapse output transforms. - `initialize_transforms_per_stage` (boolean) - Whether to initialize transforms per stage. - `metric` (list of strings) - Similarity metric to use for each stage. - `metric_weight` (list of floats) - Weight for each metric. - `radius_or_number_of_bins` (list of integers) - Radius or number of bins for the metric. - `sampling_strategy` (list of strings or None) - Sampling strategy for the metric. - `sampling_percentage` (list of floats or None) - Percentage of samples to use. - `convergence_threshold` (list of floats) - Convergence threshold for each stage. - `convergence_window_size` (list of integers) - Window size for convergence check. - `smoothing_sigmas` (list of lists of floats) - Smoothing sigmas for the metric. - `sigma_units` (list of strings) - Units for smoothing sigmas ('vox' or 'mm'). - `shrink_factors` (list of lists of integers) - Shrink factors for each stage. - `use_estimate_learning_rate_once` (list of booleans) - Whether to estimate learning rate once. - `use_histogram_matching` (list of booleans) - Whether to use histogram matching. - `output_warped_image` (string) - Path for the output warped image. ### Request Example ```python import copy, pprint from nipype.interfaces.ants import Registration reg = Registration() reg.inputs.fixed_image = 'fixed1.nii' reg.inputs.moving_image = 'moving1.nii' reg.inputs.output_transform_prefix = "output_" reg.inputs.initial_moving_transform = 'trans.mat' reg.inputs.transforms = ['Affine', 'SyN'] reg.inputs.transform_parameters = [(2.0,), (0.25, 3.0, 0.0)] reg.inputs.number_of_iterations = [[1500, 200], [100, 50, 30]] reg.inputs.dimension = 3 reg.inputs.write_composite_transform = True reg.inputs.collapse_output_transforms = False reg.inputs.initialize_transforms_per_stage = False reg.inputs.metric = ['Mattes']*2 reg.inputs.metric_weight = [1]*2 # Default (value ignored currently by ANTs) reg.inputs.radius_or_number_of_bins = [32]*2 reg.inputs.sampling_strategy = ['Random', None] reg.inputs.sampling_percentage = [0.05, None] reg.inputs.convergence_threshold = [1.e-8, 1.e-9] reg.inputs.convergence_window_size = [20]*2 reg.inputs.smoothing_sigmas = [[1,0], [2,1,0]] reg.inputs.sigma_units = ['vox'] * 2 reg.inputs.shrink_factors = [[2,1], [3,2,1]] reg.inputs.use_estimate_learning_rate_once = [True, True] reg.inputs.use_histogram_matching = [True, True] # This is the default reg.inputs.output_warped_image = 'output_warped_image.nii.gz' print(reg.cmdline) # Expected output: antsRegistration --collapse-output-transforms 0 --dimensionality 3 --initial-moving-transform [ trans.mat, 0 ] --initialize-transforms-per-stage 0 --interpolation Linear --output [ output_, output_warped_image.nii.gz ] --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, Random, 0.05 ] --convergence [ 1500x200, 1e-08, 20 ] --smoothing-sigmas 1.0x0.0vox --shrink-factors 2x1 --use-histogram-matching 1 --transform SyN[ 0.25, 3.0, 0.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --convergence [ 100x50x30, 1e-09, 20 ] --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 --use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] --write-composite-transform 1 reg.run() ``` ``` -------------------------------- ### Initialize and Configure Bru2 Converter Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.bru2nii.md Instantiate the Bru2 converter and set the input directory. This example shows basic setup for file conversion. ```python >>> from nipype.interfaces.bru2nii import Bru2 >>> converter = Bru2() >>> converter.inputs.input_dir = "brukerdir" >>> converter.cmdline 'Bru2 -o .../data/brukerdir brukerdir' ``` -------------------------------- ### Qwarp with inilev and iniwarp options Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.afni.preprocess.md This example shows how to initialize Qwarp with specific level settings ('inilev') and an initial warp file ('iniwarp'). This is useful for iterative registration or when starting from a previous warp result. ```python >>> qwarp2 = afni.Qwarp() >>> qwarp2.inputs.in_file = 'structural.nii' >>> qwarp2.inputs.base_file = 'mni.nii' >>> qwarp2.inputs.blur = [0,2] >>> qwarp2.inputs.out_file = 'Q11' >>> qwarp2.inputs.inilev = 7 >>> qwarp2.inputs.iniwarp = ['Q25_warp+tlrc.HEAD'] >>> qwarp2.cmdline '3dQwarp -base mni.nii -blur 0.0 2.0 -source structural.nii -inilev 7 -iniwarp Q25_warp+tlrc.HEAD -prefix Q11' ``` ```python >>> res2 = qwarp2.run() >>> res2 = qwarp2.run() ``` -------------------------------- ### Install Nipype from Source Source: https://github.com/nipy/nipype/blob/master/doc/users/install.md Install Nipype by downloading and unpacking the source distribution, then using pip. ```bash pip install . ``` -------------------------------- ### setup Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.sphinxext.plot_workflow.md Sphinx extension setup function. This function is called by Sphinx when the extension is loaded. ```APIDOC ### nipype.sphinxext.plot_workflow.setup(app) ``` -------------------------------- ### Basic MultiChannelNewSegment Usage Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.spm.preprocess.md This example demonstrates the basic setup for the MultiChannelNewSegment interface, specifying a single channel for segmentation. ```python >>> import nipype.interfaces.spm as spm >>> seg = spm.MultiChannelNewSegment() >>> seg.inputs.channels = [('structural.nii',(0.0001, 60, (True, True)))] >>> seg.run() ``` -------------------------------- ### FitQt1 Interface Example Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.niftyfit.qt1.md Demonstrates how to instantiate the FitQt1 interface and set the source file. Shows the resulting command-line arguments. ```python >>> from nipype.interfaces.niftyfit import FitQt1 >>> fit_qt1 = FitQt1() >>> fit_qt1.inputs.source_file = 'TI4D.nii.gz' >>> fit_qt1.cmdline 'fit_qt1 -source TI4D.nii.gz -comp TI4D_comp.nii.gz -error TI4D_error.nii.gz -m0map TI4D_m0map.nii.gz -mcmap TI4D_mcmap.nii.gz -res TI4D_res.nii.gz -syn TI4D_syn.nii.gz -t1map TI4D_t1map.nii.gz' ``` -------------------------------- ### Initialize and Configure QwarpPlusMinus Interface Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.afni.preprocess.md Demonstrates how to initialize the QwarpPlusMinus interface and set essential input files and options. The 'cmdline' attribute shows the generated command-line string. ```python >>> from nipype.interfaces import afni >>> qwarp = afni.QwarpPlusMinus() >>> qwarp.inputs.in_file = 'sub-01_dir-LR_epi.nii.gz' >>> qwarp.inputs.nopadWARP = True >>> qwarp.inputs.base_file = 'sub-01_dir-RL_epi.nii.gz' >>> qwarp.cmdline '3dQwarp -prefix Qwarp.nii.gz -plusminus -base sub-01_dir-RL_epi.nii.gz -source sub-01_dir-LR_epi.nii.gz -nopadWARP' ``` -------------------------------- ### BBRegister Example Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.freesurfer.preprocess.md Example of initializing and running the BBRegister interface to perform registration. Shows how to set subject ID, source file, and contrast type, and displays the generated command line. ```python >>> from nipype.interfaces.freesurfer import BBRegister >>> bbreg = BBRegister(subject_id='me', source_file='structural.nii', init='header', contrast_type='t2') >>> bbreg.cmdline 'bbregister --t2 --init-header --reg structural_bbreg_me.dat --mov structural.nii --s me' ``` -------------------------------- ### Get SPM Info Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.spm.base.md Retrieves information about the SPM installation, such as its path, name, and version. This method can be configured with custom MATLAB commands and paths. ```python spm.Info.getinfo() ``` -------------------------------- ### Run FSL BET Interface Source: https://github.com/nipy/nipype/blob/master/doc/users/examples/workshop_dartmouth_2010.md Example of using the FSL BET interface to perform brain extraction. Requires FSL to be installed and data/s1/struct.nii to exist. ```python from __future__ import print_function from builtins import str import nipype.interfaces.fsl as fsl result = fsl.BET(in_file='data/s1/struct.nii').run() print(result) ``` -------------------------------- ### Using NwarpCat Interface Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.afni.utils.md Demonstrates how to instantiate and configure the NwarpCat interface with input files and an output file name. It also shows how to access the generated command line and run the process. ```python from nipype.interfaces import afni nwarpcat = afni.NwarpCat() nwarpcat.inputs.in_files = ['Q25_warp+tlrc.HEAD', ('IDENT', 'structural.nii')] nwarpcat.inputs.out_file = 'Fred_total_WARP' print(nwarpcat.cmdline) res = nwarpcat.run() ``` -------------------------------- ### Cluster Example Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.fsl.model.md Demonstrates how to instantiate and configure the Cluster class with input file, threshold, and output file settings. Shows the generated command line. ```python >>> cl = Cluster() >>> cl.inputs.threshold = 2.3 >>> cl.inputs.in_file = 'zstat1.nii.gz' >>> cl.inputs.out_localmax_txt_file = 'stats.txt' >>> cl.inputs.use_mm = True >>> cl.cmdline 'cluster --in=zstat1.nii.gz --olmax=stats.txt --thresh=2.3000000000 --mm' ``` -------------------------------- ### Import necessary modules and test data Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.minc.minc.md Imports the Beast interface and a function to get test data. This is a common setup for using Nipype interfaces. ```python from nipype.interfaces.minc import Beast from nipype.interfaces.minc.testdata import nonempty_minc_data ``` -------------------------------- ### MNIBiasCorrection Example Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.freesurfer.preprocess.md Shows how to apply MNIBiasCorrection for correcting intensity non-uniformity in MRI images. This interface wraps the MNI nu_correct tool and requires MNI software to be installed. ```python >>> from nipype.interfaces.freesurfer import MNIBiasCorrection >>> correct = MNIBiasCorrection() >>> correct.inputs.in_file = "norm.mgz" >>> correct.inputs.iterations = 6 >>> correct.inputs.protocol_iterations = 1000 >>> correct.inputs.distance = 50 >>> correct.cmdline 'mri_nu_correct.mni --distance 50 --i norm.mgz --n 6 --o norm_output.mgz --proto-iters 1000' ``` -------------------------------- ### SimpleInterface Setup Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.base.core.md Illustrates the setup for a SimpleInterface, including defining input and output specifications and a helper function. This pattern is useful for creating interfaces that wrap simple Python functions with type checking. ```python >>> from nipype.interfaces.base import ( ... SimpleInterface, BaseInterfaceInputSpec, TraitedSpec) >>> import traits ``` ```python >>> def double(x): ... return 2 * x ... >>> class DoubleInputSpec(BaseInterfaceInputSpec): ... x = traits.Float(mandatory=True) ... >>> class DoubleOutputSpec(TraitedSpec): ... doubled = traits.Float() ... >>> class Double(SimpleInterface): ... input_spec = DoubleInputSpec ... output_spec = DoubleOutputSpec ... ... def _run_interface(self, runtime): ... self._results['doubled'] = double(self.inputs.x) ... return runtime ``` -------------------------------- ### Using XfmAvg Interface Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.minc.minc.md Demonstrates how to instantiate and run the XfmAvg interface with an example file. ```python >>> xfm = example_data('minc_initial.xfm') >>> invert = XfmAvg(input_file=xfm) >>> invert.run() ``` -------------------------------- ### Check Package Dependencies for Tutorial Source: https://github.com/nipy/nipype/blob/master/doc/users/examples/dmri_dtk_dti.md Confirms that required packages like numpy, scipy, and IPython are installed with specific version requirements. This is typically for tutorial setups and not for regular code. ```python from nipype.utils.misc import package_check package_check('numpy', '1.3', 'tutorial1') package_check('scipy', '0.7', 'tutorial1') package_check('IPython', '0.10', 'tutorial1') ``` -------------------------------- ### Initialize and Run BBox Interface Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.minc.minc.md Demonstrates how to import the BBox interface, load a sample MINC file, initialize the interface with the input file, and execute the command. ```python >>> from nipype.interfaces.minc import BBox >>> from nipype.interfaces.minc.testdata import nonempty_minc_data ``` ```python >>> file0 = nonempty_minc_data(0) >>> bbox = BBox(input_file=file0) >>> bbox.run() ``` -------------------------------- ### Basic ANTs Registration Setup Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.ants.registration.md Sets up a basic 3D image registration with Affine and SyN transforms. This example demonstrates configuring multiple stages of registration with specific parameters for each. ```python >>> import copy, pprint >>> from nipype.interfaces.ants import Registration >>> reg = Registration() >>> reg.inputs.fixed_image = 'fixed1.nii' >>> reg.inputs.moving_image = 'moving1.nii' >>> reg.inputs.output_transform_prefix = "output_" >>> reg.inputs.initial_moving_transform = 'trans.mat' >>> reg.inputs.transforms = ['Affine', 'SyN'] >>> reg.inputs.transform_parameters = [(2.0,), (0.25, 3.0, 0.0)] >>> reg.inputs.number_of_iterations = [[1500, 200], [100, 50, 30]] >>> reg.inputs.dimension = 3 >>> reg.inputs.write_composite_transform = True >>> reg.inputs.collapse_output_transforms = False >>> reg.inputs.initialize_transforms_per_stage = False >>> reg.inputs.metric = ['Mattes']*2 >>> reg.inputs.metric_weight = [1]*2 # Default (value ignored currently by ANTs) >>> reg.inputs.radius_or_number_of_bins = [32]*2 >>> reg.inputs.sampling_strategy = ['Random', None] >>> reg.inputs.sampling_percentage = [0.05, None] >>> reg.inputs.convergence_threshold = [1.e-8, 1.e-9] >>> reg.inputs.convergence_window_size = [20]*2 >>> reg.inputs.smoothing_sigmas = [[1,0], [2,1,0]] >>> reg.inputs.sigma_units = ['vox'] * 2 >>> reg.inputs.shrink_factors = [[2,1], [3,2,1]] >>> reg.inputs.use_estimate_learning_rate_once = [True, True] >>> reg.inputs.use_histogram_matching = [True, True] # This is the default >>> reg.inputs.output_warped_image = 'output_warped_image.nii.gz' >>> reg.cmdline 'antsRegistration --collapse-output-transforms 0 --dimensionality 3 --initial-moving-transform [ trans.mat, 0 ] --initialize-transforms-per-stage 0 --interpolation Linear --output [ output_, output_warped_image.nii.gz ] --transform Affine[ 2.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32, Random, 0.05 ] --convergence [ 1500x200, 1e-08, 20 ] --smoothing-sigmas 1.0x0.0vox --shrink-factors 2x1 --use-histogram-matching 1 --transform SyN[ 0.25, 3.0, 0.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --convergence [ 100x50x30, 1e-09, 20 ] --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 --use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] --write-composite-transform 1' >>> reg.run() ``` -------------------------------- ### Get Image Information with MRTrixInfo Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.mrtrix.preprocess.md Use MRTrixInfo to retrieve header information from an image file. This example shows how to import the interface, instantiate it, set the input file, and run the command. ```python >>> import nipype.interfaces.mrtrix as mrt >>> MRinfo = mrt.MRTrixInfo() >>> MRinfo.inputs.in_file = 'dwi.mif' >>> MRinfo.run() ``` -------------------------------- ### Instantiate and Run Pik Interface Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.minc.minc.md Demonstrates how to instantiate the Pik interface with input file and title, and then run the process. ```python file0 = nonempty_minc_data(0) pik = Pik(input_file=file0, title='foo') pik .run() ``` -------------------------------- ### Running TOPUP with specified inputs Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.fsl.epi.md This snippet shows how to instantiate and configure the TOPUP interface with input files and encoding parameters. It then prints the generated command line and executes the command. ```python from nipype.interfaces.fsl import TOPUP topup = TOPUP() topup.inputs.in_file = "b0_b0rev.nii" topup.inputs.encoding_file = "topup_encoding.txt" topup.inputs.output_type = "NIFTI_GZ" print(topup.cmdline) res = topup.run() ``` -------------------------------- ### Get FSL Info and Output Type Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.fsl.base.md Demonstrates how to retrieve the FSL version and the current default output type using the Info class. Ensure FSL is installed and configured in your environment. ```python >>> from nipype.interfaces.fsl import Info >>> Info.version() >>> Info.output_type() ``` -------------------------------- ### Set up Virtual Environment and Install Nipype Source: https://github.com/nipy/nipype/wiki/Contributing Use this snippet to create a development environment using virtualenvwrapper, clone the Nipype repository, install dependencies, and set up the project for development. ```bash WORKON_HOME=${VENV_DIR} git clone ${NIPYPE} cd nipype git checkout master PROJECT_HOME=${PWD} mkvirtualenv dev.nipype pip install numpy pip install nipype pip install ipython sphinx matplotlib #<-- needed to run complete test suite python setup.py install make specs python setup.py develop ``` -------------------------------- ### Nipype Freesurfer ReconAll Basic Example Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.freesurfer.preprocess.md Illustrates the basic setup for the ReconAll interface, specifying subject ID, directive, subjects directory, and T1 files. Shows the initial command line. ```python >>> from nipype.interfaces.freesurfer import ReconAll >>> reconall = ReconAll() >>> reconall.inputs.subject_id = 'foo' >>> reconall.inputs.directive = 'all' >>> reconall.inputs.subjects_dir = '.' >>> reconall.inputs.T1_files = ['structural.nii'] >>> reconall.cmdline 'recon-all -all -i structural.nii -subjid foo -sd .' ``` -------------------------------- ### RegF3D Example Usage Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.niftyreg.reg.md Demonstrates how to instantiate and configure the RegF3D interface with input files and parameters. Shows the generated command line. ```python >>> from nipype.interfaces import niftyreg >>> node = niftyreg.RegF3D() >>> node.inputs.ref_file = 'im1.nii' >>> node.inputs.flo_file = 'im2.nii' >>> node.inputs.rmask_file = 'mask.nii' >>> node.inputs.omp_core_val = 4 >>> node.cmdline 'reg_f3d -cpp im2_cpp.nii.gz -flo im2.nii -omp 4 -ref im1.nii -res im2_res.nii.gz -rmask mask.nii' ``` -------------------------------- ### Basic TProject Usage Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.afni.preprocess.md Example demonstrating how to use the TProject interface to set input file, bandpass filter, polynomial order, automask, and output file. This snippet shows the typical setup for nuisance signal projection. ```python >>> from nipype.interfaces import afni >>> tproject = afni.TProject() >>> tproject.inputs.in_file = 'functional.nii' >>> tproject.inputs.bandpass = (0.00667, 99999) >>> tproject.inputs.polort = 3 >>> tproject.inputs.automask = True >>> tproject.inputs.out_file = 'projected.nii.gz' >>> tproject.cmdline '3dTproject -input functional.nii -automask -bandpass 0.00667 99999 -polort 3 -prefix projected.nii.gz' >>> res = tproject.run() ``` -------------------------------- ### Log Node Callback Setup for Gantt Chart Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.utils.draw_gantt_chart.md This example demonstrates how to set up logging to generate the callback log file needed for `generate_gantt_chart`. It involves configuring a logger and handler to capture node execution details during workflow runs. ```python import logging import logging.handlers from nipype.utils.profiler import log_nodes_cb log_filename = 'callback.log' logger = logging.getLogger('callback') logger.setLevel(logging.DEBUG) handler = logging.FileHandler(log_filename) logger.addHandler(handler) # Placeholder for workflow creation and execution # workflow = ... # workflow.run(plugin='MultiProc', # plugin_args={'n_procs': 8, 'memory': 12, 'status_callback': log_nodes_cb}) # After workflow execution, generate the chart: # generate_gantt_chart(log_filename, 8) ``` -------------------------------- ### Initialize and run Similarity interface Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.nipy.utils.md Demonstrates how to initialize the Similarity interface, set input volumes and masks, specify the similarity metric, and run the interface. This example requires input files 'rc1s1.nii', 'rc1s2.nii', and 'mask.nii' to exist. ```python from nipype.interfaces.nipy.utils import Similarity similarity = Similarity() similarity.inputs.volume1 = 'rc1s1.nii' similarity.inputs.volume2 = 'rc1s2.nii' similarity.inputs.mask1 = 'mask.nii' similarity.inputs.mask2 = 'mask.nii' similarity.inputs.metric = 'cr' res = similarity.run() ``` -------------------------------- ### setup Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.sphinxext.documenter.md Sphinx setup function for the documenter extension. ```APIDOC ## nipype.sphinxext.documenter.setup(app) ### Description Sphinx setup function for the documenter extension. ### Parameters #### app (object) - Required - The Sphinx application instance. ``` -------------------------------- ### TalairachQC Interface Example Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.freesurfer.utils.md Shows how to set up the TalairachQC interface to process a log file. The log file must exist prior to execution. ```python >>> from nipype.interfaces.freesurfer import TalairachQC >>> qc = TalairachQC() >>> qc.inputs.log_file = 'dirs.txt' >>> qc.cmdline 'tal_QC_AZS dirs.txt' ``` -------------------------------- ### Instantiate and Use Quickshear Interface Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.quickshear.md Instantiate the Quickshear interface with input and mask files, then print the generated command line. This is useful for understanding how the interface translates inputs to command-line arguments. ```python from nipype.interfaces.quickshear import Quickshear qs = Quickshear(in_file='T1.nii', mask_file='brain_mask.nii') qs.cmdline ``` -------------------------------- ### Install Nipype with Pip Source: https://github.com/nipy/nipype/blob/master/doc/users/install.md Install the latest stable version of Nipype using pip. ```bash pip install nipype ``` -------------------------------- ### Test Nipype Installation Source: https://github.com/nipy/nipype/blob/master/doc/users/install.md Verify the Nipype installation by checking its version and running the built-in tests. ```python python -c "import nipype; print(nipype.__version__)" ``` ```python python -c "import nipype; nipype.test()" ``` -------------------------------- ### Initialize Contrast Interface Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.freesurfer.utils.md Demonstrates how to import and instantiate the Contrast interface for Freesurfer. ```python >>> from nipype.interfaces.freesurfer import Contrast >>> contrast = Contrast() >>> contrast.inputs.subject_id = '10335' >>> contrast.inputs.hemisphere = 'lh' >>> contrast.inputs.white = 'lh.white' >>> contrast.inputs.thickness = 'lh.thickness' >>> contrast.inputs.annotation = '../label/lh.aparc.annot' >>> contrast.inputs.cortex = '../label/lh.cortex.label' >>> contrast.inputs.rawavg = '../mri/rawavg.mgz' >>> contrast.inputs.orig = '../mri/orig.mgz' >>> contrast.cmdline 'pctsurfcon --lh-only --s 10335' ``` -------------------------------- ### Initialize and Configure DenoiseImage Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.ants.md Demonstrates basic initialization of the DenoiseImage interface, setting the dimension and input image, and shows the generated command line. ```python import copy from nipype.interfaces.ants import DenoiseImage denoise = DenoiseImage() denoise.inputs.dimension = 3 denoise.inputs.input_image = 'im1.nii' denoise.cmdline ``` -------------------------------- ### Instantiate and run the Beast interface Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.minc.minc.md Demonstrates how to instantiate the Beast interface with an input file and execute it. Ensure the input file path is correctly specified. ```python file0 = nonempty_minc_data(0) beast = Beast(input_file=file0) beast.run() ``` -------------------------------- ### Install Nipype with Conda Source: https://github.com/nipy/nipype/blob/master/doc/users/install.md Install Nipype from the conda-forge channel using the conda package manager. ```bash conda install --channel conda-forge nipype ``` -------------------------------- ### Install Nipype Dependencies Source: https://github.com/nipy/nipype/blob/master/doc/devel/testing_nipype.md Install required dependencies and the development version of Nipype after cloning the repository. ```bash cd nipype pip install -r requirements.txt pip install -e .[dev] ``` -------------------------------- ### Using Binarize to Threshold a Volume Source: https://github.com/nipy/nipype/blob/master/doc/api/generated/nipype.interfaces.freesurfer.model.md This example demonstrates how to use the Binarize interface to threshold an input volume. It shows how to set the input file, minimum threshold, and the output binary file name. The resulting command line is also displayed. ```python >>> binvol = Binarize(in_file='structural.nii', min=10, binary_file='foo_out.nii') >>> binvol.cmdline 'mri_binarize --o foo_out.nii --i structural.nii --min 10.000000' ``` -------------------------------- ### Install Nipype with All Optional Features Source: https://github.com/nipy/nipype/blob/master/doc/users/install.md Install Nipype along with all its optional dependencies and features using pip. ```bash pip install nipype[all] ```