Skip to content

Commit 1a476bd

Browse files
authored
Merge pull request #3437 from mnoergaard/add_pet_freesurfer
[ENH] Add PETsurfer to nipype
2 parents ecd5871 + 06e1193 commit 1a476bd

17 files changed

+1942
-14
lines changed

nipype/interfaces/freesurfer/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,7 @@
9393
Paint,
9494
MRICoreg,
9595
)
96+
from .petsurfer import (
97+
GTMSeg,
98+
GTMPVC,
99+
)

nipype/interfaces/freesurfer/model.py

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,26 @@ class GLMFitInputSpec(FSTraitedSpec):
401401
synth = traits.Bool(argstr="--synth", desc="replace input with gaussian")
402402
resynth_test = traits.Int(argstr="--resynthtest %d", desc="test GLM by resynthsis")
403403
profile = traits.Int(argstr="--profile %d", desc="niters : test speed")
404+
mrtm1 = traits.Tuple(
405+
File(exists=True),
406+
File(exists=True),
407+
argstr="--mrtm1 %s %s",
408+
desc="RefTac TimeSec : perform MRTM1 kinetic modeling",
409+
)
410+
mrtm2 = traits.Tuple(
411+
File(exists=True),
412+
File(exists=True),
413+
traits.Float,
414+
argstr="--mrtm2 %s %s %f",
415+
desc="RefTac TimeSec k2prime : perform MRTM2 kinetic modeling",
416+
)
417+
logan = traits.Tuple(
418+
File(exists=True),
419+
File(exists=True),
420+
traits.Float,
421+
argstr="--logan %s %s %f",
422+
desc="RefTac TimeSec tstar : perform Logan kinetic modeling",
423+
)
404424
force_perm = traits.Bool(
405425
argstr="--perm-force",
406426
desc="force perumtation test, even when design matrix is not orthog",
@@ -423,6 +443,9 @@ class GLMFitInputSpec(FSTraitedSpec):
423443
sim_done_file = File(
424444
argstr="--sim-done %s", desc="create file when simulation finished"
425445
)
446+
_ext_xor = ['nii', 'nii_gz']
447+
nii = traits.Bool(argstr='--nii', desc='save outputs as nii', xor=_ext_xor)
448+
nii_gz = traits.Bool(argstr='--nii.gz', desc='save outputs as nii.gz', xor=_ext_xor)
426449

427450

428451
class GLMFitOutputSpec(TraitedSpec):
@@ -444,6 +467,8 @@ class GLMFitOutputSpec(TraitedSpec):
444467
frame_eigenvectors = File(desc="matrix of frame eigenvectors from residual PCA")
445468
singular_values = File(desc="matrix singular values from residual PCA")
446469
svd_stats_file = File(desc="text file summarizing the residual PCA")
470+
k2p_file = File(desc="estimate of k2p parameter")
471+
bp_file = File(desc="Binding potential estimates")
447472

448473

449474
class GLMFit(FSCommand):
@@ -478,22 +503,33 @@ def _list_outputs(self):
478503
glmdir = os.path.abspath(self.inputs.glm_dir)
479504
outputs["glm_dir"] = glmdir
480505

506+
if isdefined(self.inputs.nii_gz):
507+
ext = 'nii.gz'
508+
elif isdefined(self.inputs.nii):
509+
ext = 'nii'
510+
else:
511+
ext = 'mgh'
512+
481513
# Assign the output files that always get created
482-
outputs["beta_file"] = os.path.join(glmdir, "beta.mgh")
483-
outputs["error_var_file"] = os.path.join(glmdir, "rvar.mgh")
484-
outputs["error_stddev_file"] = os.path.join(glmdir, "rstd.mgh")
485-
outputs["mask_file"] = os.path.join(glmdir, "mask.mgh")
514+
outputs["beta_file"] = os.path.join(glmdir, f"beta.{ext}")
515+
outputs["error_var_file"] = os.path.join(glmdir, f"rvar.{ext}")
516+
outputs["error_stddev_file"] = os.path.join(glmdir, f"rstd.{ext}")
517+
outputs["mask_file"] = os.path.join(glmdir, f"mask.{ext}")
486518
outputs["fwhm_file"] = os.path.join(glmdir, "fwhm.dat")
487519
outputs["dof_file"] = os.path.join(glmdir, "dof.dat")
488520
# Assign the conditional outputs
489-
if isdefined(self.inputs.save_residual) and self.inputs.save_residual:
490-
outputs["error_file"] = os.path.join(glmdir, "eres.mgh")
491-
if isdefined(self.inputs.save_estimate) and self.inputs.save_estimate:
492-
outputs["estimate_file"] = os.path.join(glmdir, "yhat.mgh")
521+
if self.inputs.save_residual:
522+
outputs["error_file"] = os.path.join(glmdir, f"eres.{ext}")
523+
if self.inputs.save_estimate:
524+
outputs["estimate_file"] = os.path.join(glmdir, f"yhat.{ext}")
525+
if any((self.inputs.mrtm1, self.inputs.mrtm2, self.inputs.logan)):
526+
outputs["bp_file"] = os.path.join(glmdir, f"bp.{ext}")
527+
if self.inputs.mrtm1:
528+
outputs["k2p_file"] = os.path.join(glmdir, "k2prime.dat")
493529

494530
# Get the contrast directory name(s)
531+
contrasts = []
495532
if isdefined(self.inputs.contrast):
496-
contrasts = []
497533
for c in self.inputs.contrast:
498534
if split_filename(c)[2] in [".mat", ".dat", ".mtx", ".con"]:
499535
contrasts.append(split_filename(c)[1])
@@ -503,19 +539,19 @@ def _list_outputs(self):
503539
contrasts = ["osgm"]
504540

505541
# Add in the contrast images
506-
outputs["sig_file"] = [os.path.join(glmdir, c, "sig.mgh") for c in contrasts]
507-
outputs["ftest_file"] = [os.path.join(glmdir, c, "F.mgh") for c in contrasts]
542+
outputs["sig_file"] = [os.path.join(glmdir, c, f"sig.{ext}") for c in contrasts]
543+
outputs["ftest_file"] = [os.path.join(glmdir, c, f"F.{ext}") for c in contrasts]
508544
outputs["gamma_file"] = [
509-
os.path.join(glmdir, c, "gamma.mgh") for c in contrasts
545+
os.path.join(glmdir, c, f"gamma.{ext}") for c in contrasts
510546
]
511547
outputs["gamma_var_file"] = [
512-
os.path.join(glmdir, c, "gammavar.mgh") for c in contrasts
548+
os.path.join(glmdir, c, f"gammavar.{ext}") for c in contrasts
513549
]
514550

515551
# Add in the PCA results, if relevant
516552
if isdefined(self.inputs.pca) and self.inputs.pca:
517553
pcadir = os.path.join(glmdir, "pca-eres")
518-
outputs["spatial_eigenvectors"] = os.path.join(pcadir, "v.mgh")
554+
outputs["spatial_eigenvectors"] = os.path.join(pcadir, f"v.{ext}")
519555
outputs["frame_eigenvectors"] = os.path.join(pcadir, "u.mtx")
520556
outputs["singluar_values"] = os.path.join(pcadir, "sdiag.mat")
521557
outputs["svd_stats_file"] = os.path.join(pcadir, "stats.dat")

0 commit comments

Comments
 (0)