@@ -401,6 +401,26 @@ class GLMFitInputSpec(FSTraitedSpec):
401
401
synth = traits .Bool (argstr = "--synth" , desc = "replace input with gaussian" )
402
402
resynth_test = traits .Int (argstr = "--resynthtest %d" , desc = "test GLM by resynthsis" )
403
403
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
+ )
404
424
force_perm = traits .Bool (
405
425
argstr = "--perm-force" ,
406
426
desc = "force perumtation test, even when design matrix is not orthog" ,
@@ -423,6 +443,9 @@ class GLMFitInputSpec(FSTraitedSpec):
423
443
sim_done_file = File (
424
444
argstr = "--sim-done %s" , desc = "create file when simulation finished"
425
445
)
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 )
426
449
427
450
428
451
class GLMFitOutputSpec (TraitedSpec ):
@@ -444,6 +467,8 @@ class GLMFitOutputSpec(TraitedSpec):
444
467
frame_eigenvectors = File (desc = "matrix of frame eigenvectors from residual PCA" )
445
468
singular_values = File (desc = "matrix singular values from residual PCA" )
446
469
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" )
447
472
448
473
449
474
class GLMFit (FSCommand ):
@@ -478,22 +503,33 @@ def _list_outputs(self):
478
503
glmdir = os .path .abspath (self .inputs .glm_dir )
479
504
outputs ["glm_dir" ] = glmdir
480
505
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
+
481
513
# 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 } " )
486
518
outputs ["fwhm_file" ] = os .path .join (glmdir , "fwhm.dat" )
487
519
outputs ["dof_file" ] = os .path .join (glmdir , "dof.dat" )
488
520
# 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" )
493
529
494
530
# Get the contrast directory name(s)
531
+ contrasts = []
495
532
if isdefined (self .inputs .contrast ):
496
- contrasts = []
497
533
for c in self .inputs .contrast :
498
534
if split_filename (c )[2 ] in [".mat" , ".dat" , ".mtx" , ".con" ]:
499
535
contrasts .append (split_filename (c )[1 ])
@@ -503,19 +539,19 @@ def _list_outputs(self):
503
539
contrasts = ["osgm" ]
504
540
505
541
# 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 ]
508
544
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
510
546
]
511
547
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
513
549
]
514
550
515
551
# Add in the PCA results, if relevant
516
552
if isdefined (self .inputs .pca ) and self .inputs .pca :
517
553
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 } " )
519
555
outputs ["frame_eigenvectors" ] = os .path .join (pcadir , "u.mtx" )
520
556
outputs ["singluar_values" ] = os .path .join (pcadir , "sdiag.mat" )
521
557
outputs ["svd_stats_file" ] = os .path .join (pcadir , "stats.dat" )
0 commit comments