@@ -406,261 +406,8 @@ class XFibres5(FSLXCommand):
406
406
input_spec = XFibres5InputSpec
407
407
output_spec = FSLXCommandOutputSpec
408
408
409
-
410
- class XFibres4InputSpec (FSLCommandInputSpec ):
411
- dwi = File (exists = True , argstr = "--data=%s" , mandatory = True )
412
- mask = File (exists = True , argstr = "--mask=%s" , mandatory = True )
413
- gradnonlin = File (exists = True , argstr = "--gradnonlin=%s" )
414
- bvecs = File (exists = True , argstr = "--bvecs=%s" , mandatory = True )
415
- bvals = File (exists = True , argstr = "--bvals=%s" , mandatory = True )
416
- logdir = Directory ("logdir" , argstr = "--logdir=%s" , usedefault = True )
417
- n_fibres = traits .Range (low = 1 , argstr = "--nfibres=%d" ,
418
- desc = "Maximum nukmber of fibres to fit in each voxel" )
419
- fudge = traits .Int (argstr = "--fudge=%d" ,
420
- desc = "ARD fudge factor" )
421
- n_jumps = traits .Range (low = 1 , argstr = "--njumps=%d" ,
422
- desc = "Num of jumps to be made by MCMC" )
423
- burn_in = traits .Range (low = 0 , argstr = "--burnin=%d" ,
424
- desc = "Total num of jumps at start of MCMC to be discarded" )
425
- burn_in_no_ard = traits .Range (low = 0 , argstr = "--burninnoard=%d" ,
426
- desc = "num of burnin jumps before the ard is imposed" )
427
- sample_every = traits .Range (low = 0 , argstr = "--sampleevery=%d" ,
428
- desc = "Num of jumps for each sample (MCMC)" )
429
- update_proposal_every = traits .Range (low = 1 , argstr = "--updateproposalevery=%d" ,
430
- desc = "Num of jumps for each update to the proposal density std (MCMC)" )
431
- seed = traits .Int (argstr = "--seed=%d" , desc = "seed for pseudo random number generator" )
432
- model = traits .Int (argstr = "--model=%d" , desc = "Which model to use. \
433
- 1=mono-exponential (default and required for single shell). 2=continous \
434
- exponential (for multi-shell experiments)" )
435
-
436
- _xor_inputs1 = ('no_ard' , 'all_ard' )
437
- no_ard = traits .Bool (argstr = "--noard" , desc = "Turn ARD off on all fibres" , xor = _xor_inputs1 )
438
- all_ard = traits .Bool (argstr = "--allard" , desc = "Turn ARD on on all fibres" , xor = _xor_inputs1 )
439
-
440
- _xor_inputs2 = ('no_spat' , 'non_linear' )
441
- no_spat = traits .Bool (argstr = "--nospat" , desc = "Initialise with tensor, not spatially" , xor = _xor_inputs2 )
442
- non_linear = traits .Bool (argstr = "--nonlinear" , desc = "Initialise with nonlinear fitting" , xor = _xor_inputs2 )
443
- force_dir = traits .Bool (True ,
444
- desc = 'use the actual directory name given - i.e. ' +
445
- 'do not add + to make a new directory' ,
446
- argstr = '--forcedir' , usedefault = True )
447
-
448
-
449
- class XFibres4OutputSpec (TraitedSpec ):
450
- dyads = OutputMultiPath (File (exists = True ), desc = "Mean of PDD distribution in vector form." )
451
- fsamples = OutputMultiPath (File (exists = True ), desc = "Samples from the distribution on anisotropic volume fraction" )
452
- mean_dsamples = File (exists = True , desc = "Mean of distribution on diffusivity d" )
453
- mean_fsamples = OutputMultiPath (File (exists = True ), desc = "Mean of distribution on f anisotropy" )
454
- mean_S0samples = File (exists = True , desc = "Samples from S0 distribution" )
455
- phsamples = OutputMultiPath (File (exists = True ), desc = "Samples from the distribution on phi" )
456
- thsamples = OutputMultiPath (File (exists = True ), desc = "Samples from the distribution on theta" )
457
-
458
-
459
- class XFibres4 (FSLCommand ):
460
- """
461
- Perform model parameters estimation for local (voxelwise) diffusion
462
- parameters
463
-
464
- .. deprecated:: 0.9.2
465
- Use :class:`.XFibres5` instead.
466
-
467
-
468
- """
469
- _cmd = "xfibres"
470
- input_spec = XFibres4InputSpec
471
- output_spec = XFibres4OutputSpec
472
-
473
- def __init__ (self , ** inputs ):
474
- warnings .warn (('Deprecated: Please use XFIBERS5 instead. This '
475
- 'interface will be removed in version 0.11.' ),
476
- DeprecationWarning )
477
- super (XFibres4 , self ).__init__ (** inputs )
478
-
479
- def _list_outputs (self ):
480
- outputs = self .output_spec ().get ()
481
- outputs ["mean_dsamples" ] = self ._gen_fname ("mean_dsamples" ,
482
- cwd = self .inputs .logdir )
483
- outputs ["mean_S0samples" ] = self ._gen_fname ("mean_S0samples" ,
484
- cwd = self .inputs .logdir )
485
- outputs ["dyads" ] = []
486
- outputs ["fsamples" ] = []
487
- outputs ["mean_fsamples" ] = []
488
- outputs ["phsamples" ] = []
489
- outputs ["thsamples" ] = []
490
- for i in range (1 , self .inputs .n_fibres + 1 ):
491
- outputs ["dyads" ].append (self ._gen_fname ("dyads%d" % i ,
492
- cwd = self .inputs .logdir ))
493
- outputs ["fsamples" ].append (self ._gen_fname ("f%dsamples" % i ,
494
- cwd = self .inputs .logdir ))
495
- outputs ["mean_fsamples" ].append (self ._gen_fname ("mean_f%dsamples" % i ,
496
- cwd = self .inputs .logdir ))
497
- outputs ["phsamples" ].append (self ._gen_fname ("ph%dsamples" % i ,
498
- cwd = self .inputs .logdir ))
499
- outputs ["thsamples" ].append (self ._gen_fname ("th%dsamples" % i ,
500
- cwd = self .inputs .logdir ))
501
-
502
- return outputs
503
-
504
-
505
- class BEDPOSTX4InputSpec (XFibres4InputSpec ):
506
- dwi = File (exists = True , desc = 'diffusion weighted image data file' ,
507
- mandatory = True )
508
- mask = File (exists = True , desc = 'bet binary mask file' , mandatory = True )
509
- bvecs = File (exists = True , desc = 'b vectors file' , mandatory = True )
510
- bvals = File (exists = True , desc = 'b values file' , mandatory = True )
511
- bpx_directory = Directory ('bedpostx' , argstr = '%s' , usedefault = True ,
512
- desc = ('the name for this subject\' s bedpostx'
513
- ' folder' ))
514
- fibres = traits .Int (2 , argstr = '-n %d' , desc = 'number of fibres per voxel' )
515
- weight = traits .Float (1.00 , argstr = '-w %.2f' ,
516
- desc = ('ARD weight, more weight means less'
517
- ' secondary fibres per voxel' ))
518
- burn_period = traits .Int (1000 , argstr = '-b %d' , desc = 'burnin period' )
519
- jumps = traits .Int (1250 , argstr = '-j %d' , desc = 'number of jumps' )
520
- sampling = traits .Int (25 , argstr = '-s %d' , desc = 'sample every' )
521
- model = traits .Enum (1 , 2 , argstr = '-model %d' ,
522
- desc = ('model choice: monoexponential (1) or '
523
- 'multiexponential (2). ' ))
524
- nlgradient = traits .Bool (False , argstr = '-g' , desc = ('consider gradient'
525
- 'nonlinearities, default off' ))
526
- no_cuda = traits .Bool (False , argstr = '-c' ,
527
- desc = ('do not use CUDA capable hardware/queue '
528
- '(if found)' ))
529
-
530
-
531
- class BEDPOSTX4OutputSpec (TraitedSpec ):
532
- bpx_out_directory = Directory (exists = True ,
533
- desc = 'path/name of directory with all ' +
534
- 'bedpostx output files for this subject' )
535
- xfms_directory = Directory (exists = True ,
536
- desc = 'path/name of directory with the ' +
537
- 'tranformation matrices' )
538
- merged_thsamples = traits .List (File (exists = True ),
539
- desc = 'a list of path/name of 4D volume ' +
540
- 'with samples from the distribution ' +
541
- 'on theta' )
542
- merged_phsamples = traits .List (File (exists = True ),
543
- desc = 'a list of path/name of file with '
544
- 'samples from the distribution on phi' )
545
- merged_fsamples = traits .List (File (exists = True ),
546
- desc = 'a list of path/name of 4D volume ' +
547
- 'with samples from the distribution ' +
548
- 'on anisotropic volume fraction' )
549
- mean_thsamples = traits .List (File (exists = True ),
550
- desc = 'a list of path/name of 3D volume with mean of distribution on theta' )
551
- mean_phsamples = traits .List (File (exists = True ),
552
- desc = 'a list of path/name of 3D volume with mean of distribution on phi' )
553
- mean_fsamples = traits .List (File (exists = True ),
554
- desc = 'a list of path/name of 3D volume with mean of distribution on f anisotropy' )
555
- dyads = traits .List (File (exists = True ), desc = 'a list of path/name of mean of PDD distribution in vector form' )
556
-
557
-
558
- class BEDPOSTX4 (FSLCommand ):
559
- """
560
- bedpostx has an old interface, implemented here
561
-
562
-
563
- Example
564
- -------
565
-
566
- >>> from nipype.interfaces import fsl
567
- >>> bedp = fsl.BEDPOSTX4(bpx_directory='subjdir', bvecs='bvecs', \
568
- bvals='bvals', dwi='diffusion.nii', mask='mask.nii', fibres=1)
569
- >>> bedp.cmdline
570
- 'bedpostx subjdir -n 1 --forcedir --logdir=logdir'
571
-
572
- """
573
-
574
- _cmd = 'bedpostx'
575
- input_spec = BEDPOSTX4InputSpec
576
- output_spec = BEDPOSTX4OutputSpec
577
- _can_resume = True
578
-
579
- def __init__ (self , ** inputs ):
580
- warnings .warn (('Deprecated: Please use BEDPOSTX5 or '
581
- 'create_bedpostx_pipeline instead. This interface will '
582
- 'be removed in version 0.11.' ), DeprecationWarning )
583
- super (BEDPOSTX4 , self ).__init__ (** inputs )
584
-
585
- def _get_bedpostx_dir (self ):
586
- return os .path .join (os .getcwd (), self .inputs .bpx_directory )
587
-
588
- def _run_interface (self , runtime , correct_return_codes = [0 ]):
589
-
590
- # create the subject specific bpx_directory
591
- bpx_directory = self ._get_bedpostx_dir ()
592
- if not os .path .exists (bpx_directory ):
593
- os .makedirs (bpx_directory )
594
-
595
- _ , _ , ext = split_filename (self .inputs .mask )
596
- shutil .copyfile (self .inputs .mask ,
597
- os .path .join (self .inputs .bpx_directory ,
598
- 'nodif_brain_mask' + ext ))
599
- _ , _ , ext = split_filename (self .inputs .dwi )
600
- shutil .copyfile (self .inputs .dwi ,
601
- os .path .join (self .inputs .bpx_directory , 'data' + ext ))
602
- shutil .copyfile (self .inputs .bvals ,
603
- os .path .join (self .inputs .bpx_directory , 'bvals' ))
604
- shutil .copyfile (self .inputs .bvecs ,
605
- os .path .join (self .inputs .bpx_directory , 'bvecs' ))
606
-
607
- runtime = super (BEDPOSTX4 , self )._run_interface (runtime ,
608
- correct_return_codes )
609
- if runtime .stderr :
610
- self .raise_exception (runtime )
611
- return runtime
612
-
613
- def _list_outputs (self ):
614
- outputs = self .output_spec ().get ()
615
- bpx_directory = self ._get_bedpostx_dir ()
616
- outputs ['bpx_out_directory' ] = os .path .join (bpx_directory + '.bedpostX' )
617
- outputs ['xfms_directory' ] = os .path .join (bpx_directory + '.bedpostX' ,
618
- 'xfms' )
619
-
620
- for k in list (outputs .keys ()):
621
- if k not in ('outputtype' , 'environ' , 'args' , 'bpx_out_directory' ,
622
- 'xfms_directory' ):
623
- outputs [k ] = []
624
-
625
- for n in range (self .inputs .fibres ):
626
- outputs ['merged_thsamples' ].append (self ._gen_fname (
627
- 'merged_th' + repr (n + 1 ) + 'samples' ,
628
- suffix = '' , cwd = outputs ['bpx_out_directory' ]))
629
- outputs ['merged_phsamples' ].append (self ._gen_fname (
630
- 'merged_ph' + repr (n + 1 ) + 'samples' ,
631
- suffix = '' , cwd = outputs ['bpx_out_directory' ]))
632
- outputs ['merged_fsamples' ].append (self ._gen_fname (
633
- 'merged_f' + repr (n + 1 ) + 'samples' ,
634
- suffix = '' , cwd = outputs ['bpx_out_directory' ]))
635
- outputs ['mean_thsamples' ].append (self ._gen_fname (
636
- 'mean_th' + repr (n + 1 ) + 'samples' ,
637
- suffix = '' , cwd = outputs ['bpx_out_directory' ]))
638
- outputs ['mean_phsamples' ].append (self ._gen_fname (
639
- 'mean_ph' + repr (n + 1 ) + 'samples' ,
640
- suffix = '' , cwd = outputs ['bpx_out_directory' ]))
641
- outputs ['mean_fsamples' ].append (self ._gen_fname (
642
- 'mean_f' + repr (n + 1 ) + 'samples' ,
643
- suffix = '' , cwd = outputs ['bpx_out_directory' ]))
644
- outputs ['dyads' ].append (self ._gen_fname (
645
- 'dyads' + repr (n + 1 ),
646
- suffix = '' , cwd = outputs ['bpx_out_directory' ]))
647
- return outputs
648
-
649
-
650
- if (Info .version () and LooseVersion (Info .version ()) >= LooseVersion ('5.0.0' )):
651
- CurrentXFibres = XFibres5
652
- CurrentBEDPOST = BEDPOSTX5
653
- else :
654
- CurrentXFibres = XFibres4
655
- CurrentBEDPOST = BEDPOSTX4
656
-
657
-
658
- class XFibres (CurrentXFibres ):
659
- pass
660
-
661
-
662
- class BEDPOSTX (CurrentBEDPOST ):
663
- pass
409
+ XFibres = XFibres5
410
+ BEDPOSTX = BEDPOSTX5
664
411
665
412
666
413
class ProbTrackXBaseInputSpec (FSLCommandInputSpec ):
0 commit comments