Package: nipype-generate-fieldmaps
nipype-generate-fieldmapsNipype workflow to generate fieldmaps from EPI acquisitions with differing phase-encoding directionsInstallationpipinstallnipype-generate-fieldmapsUsageAs a stand-alone workflow# create the workflowwf=create_generate_fieldmaps_wf()# wire-up the inputswf.inputs.inputnode.se_epi_pe1_file=my_se_epi_pe1_file# type: str | Pathwf.inputs.inputnode.se_epi_pe2_file=my_se_epi_pe2_file# type: str | Pathwf.inputs.inputnode.se_epi_pe1_sidecar_file=my_se_epi_pe1_sidecar_file# type: str | Pathwf.inputs.inputnode.se_epi_pe2_sidecar_file=my_se_epi_pe2_sidecar_file# type: str | Path# set the output directorywf.base_dir=my_output_dir# type: str | Path# run itwf.run()As a nested workflowThe nodesnode1,node2,some_other_node,maybe_a_4th_node,epi_node, andanat_nodeare made up for demonstration purposesfromnipypeimportWorkflowfromnipype.interfaces.fslimportEpiRegfromnipype_generate_fieldmapsimportcreate_generate_fieldmaps_wf# parent workflow defined elsewherewf=Workflow(...)# create the (sub-)workflowfmap_wf=create_generate_fieldmaps_wf()# connect the various nodes form the parent workflow to the nested fieldmap workflowwf.connect(node1,'out_file',fmap_wf,'inputnode.se_epi_pe1_file')wf.connect(node2,'out',fmap_wf,'inputnode.se_epi_pe2_file')wf.connect(some_other_node,'output_file',fmap_wf,'inputnode.se_epi_pe1_sidecar_file')wf.connect(maybe_a_4th_node,'sidecar_file',fmap_wf,'inputnode.se_epi_pe2_sidecar_file')# connect the fieldmap workflow outputs to one (or more) node(s) in the parent workflow# for example: EpiReg()epireg=Node(EpiReg(out_base='epi2str.nii.gz'),name='epi_reg')# from elsewherewf.connect(epi_node,'my_epi_file'epireg,'epi')wf.connect(anat_node,'my_t1_file',epireg,'t1_head')wf.connect(anat_node,'my_t1_brain_file',epireg,'t1_brain')# from the fieldmap workflow!wf.connect(fmap_wf,'outputnode.fmap_rads_file',epireg,'fmap')wf.connect(fmap_wf,'outputnode.fmap_mag_file',epireg,'fmapmag')wf.connect(fmap_wf,'outputnode.fmap_mag_brain_file',epireg,'fmapmagbrain')wf.connect(fmap_wf,'outputnode.echo_spacing',epireg,'echospacing')wf.connect(fmap_wf,'outputnode.pe1_pedir',epireg,'pedir')From the command line$nipype-generate-fieldmaps--help
usage:nipype-generate-fieldmaps[-h][-v]se_epi_pe1se_epi_pe2se_epi_pe1_sidecarse_epi_pe2_sidecarout_dir

GeneratefieldmapsfromEPIacquisitionswithdifferingphase-encodingdirections

positionalarguments:se_epi_pe1Thespin-echoEPIfileacquiredinthe'first'phase-encodingdirectionse_epi_pe2Thespin-echoEPIfileacquiredinthe'second'phase-encodingdirectionse_epi_pe1_sidecarTheJSONsidecarforthefirstspin-echoEPIfilese_epi_pe2_sidecarTheJSONsidecarforthesecondspin-echoEPIfileout_dirThedirectoryintowhichoutputsarewritten

optionalarguments:-h,--helpshowthishelpmessageandexit-v,--versionshowprogram'sversionnumberandexitPrerequisitesThis workflow has a few requirements:There aretwoacquisitions (i.e..nii.gzfiles) acquired withdifferentphase encodings, usually opposite phase encodings but this need not be the case.The number of volumes in acquisition 1 (the first phase encoding direction)equalsthe number of volumes in acquisition 2 (the second phase encoding direction)Each acquisition has a JSON sidecar. Specifically, this workflow requires thateachsidecar contain one of the following sets of properties. These properties are listed in the order in which the workflow will search:PhaseEncodingDirectionandTotalReadoutTime, orPhaseEncodingDirection,ReconMatrixPE, andEffectiveEchoSpacing, orPhaseEncodingDirection,ReconMatrixPE, andBandwidthPerPixelPhaseEncodeIf either JSON sidecar fails to contain at least one of the above sets of parameters the workflow will produce an error.I/OThis workflow requires 4 inputs to be connected to the node namedinputnode:se_epi_pe1_fileThe spin-echo EPI file acquired in the 'first' phase-encoding directionse_epi_pe2_fileThe spin-echo EPI file acquired in the 'second' phase-encoding directionse_epi_pe1_sidecar_fileThe JSON sidecar for the first spin-echo EPI filese_epi_pe2_sidecar_fileThe JSON sidecar for the second spin-echo EPI fileThis workflow also exposes the following outputs via the node namedoutputnode:acq_params_fileThe computed file passed to the--datainoption oftopupcorrected_se_epi_fileThe.nii.gzimage containing alldistortion correctedvolumes from the two input acquisitionsfmap_hz_fileThe fieldmap in hertz (Hz)fmap_rads_fileThe fieldmap in radians per second (rad/s)fmap_mag_fileThe 'magnitude' image (mean image) computed by averaging all volumes incorrected_se_epi_filefmap_mag_brain_fileThe result of applying brain-extraction tofmap_mag_filefmap_mag_brain_mask_fileThe brain mask produced during the brain-extraction offmap_mag_fileWorkflow diagramContributingHave or install a recent version ofpoetry(version >= 1.1)Fork the repoSetup a virtual environment (however you prefer)Runpoetry installRunpre-commit installAdd your changesCommit your changes + push to your forkOpen a PR