def extract_nodif_volume(outdir, dwi, bval): """ Parameters ---------- outdir: Str, path to directory where to write "b0.nii.gz" dwi: Str, path to DW data in which at least one volume was acquired with bvalue=0. bval: Str, path to .bval file associated to the DW data. Return ------ nodif_volume: Str, path to a/the volume for which bvalue is 0. <unit> <input name="outdir" type="Directory" /> <input name="dwi" type="File" /> <input name="bval" type="File" /> <output name="nodif_volume" type="File" /> </unit> """ # Get index of the first volume acquired with bvalue=0 b0_index = select_first_b0(bval) # Extract volume to a temporary Nifti nodif_volume = os.path.join(outdir, "nodif.nii.gz") extract_image(dwi, index=b0_index, out_file=nodif_volume) return nodif_volume