@@ -1338,6 +1338,121 @@ def _list_outputs(self):
1338
1338
return outputs
1339
1339
1340
1340
1341
+ class LocalBistatInputSpec (AFNICommandInputSpec ):
1342
+ in_file1 = File (
1343
+ exists = True ,
1344
+ mandatory = True ,
1345
+ argstr = '%s' ,
1346
+ position = - 2 ,
1347
+ desc = 'Filename of the first image' )
1348
+ in_file2 = File (
1349
+ exists = True ,
1350
+ mandatory = True ,
1351
+ argstr = '%s' ,
1352
+ position = - 1 ,
1353
+ desc = 'Filename of the second image' )
1354
+ neighborhood = traits .Either (
1355
+ traits .Tuple (traits .Enum ('SPHERE' , 'RHDD' , 'TOHD' ), traits .Float ()),
1356
+ traits .Tuple (traits .Enum ('RECT' ), traits .Tuple (traits .Float (),
1357
+ traits .Float (),
1358
+ traits .Float ())),
1359
+ mandatory = True ,
1360
+ desc = 'The region around each voxel that will be extracted for '
1361
+ 'the statistics calculation. Possible regions are: '
1362
+ '\' SPHERE\' , \' RHDD\' (rhombic dodecahedron), \' TOHD\' '
1363
+ '(truncated octahedron) with a given radius in mm or '
1364
+ '\' RECT\' (rectangular block) with dimensions to specify in mm.' ,
1365
+ argstr = "-nbhd '%s(%s)'" )
1366
+ _stat_names = ['pearson' , 'spearman' , 'quadrant' , 'mutinfo' , 'normuti' ,
1367
+ 'jointent' , 'hellinger' , 'crU' , 'crM' , 'crA' , 'L2slope' ,
1368
+ 'L1slope' , 'num' , 'ALL' ]
1369
+ stat = InputMultiPath (
1370
+ traits .Enum (_stat_names ),
1371
+ mandatory = True ,
1372
+ desc = 'statistics to compute. Possible names are :'
1373
+ ' * pearson = Pearson correlation coefficient'
1374
+ ' * spearman = Spearman correlation coefficient'
1375
+ ' * quadrant = Quadrant correlation coefficient'
1376
+ ' * mutinfo = Mutual Information'
1377
+ ' * normuti = Normalized Mutual Information'
1378
+ ' * jointent = Joint entropy'
1379
+ ' * hellinger= Hellinger metric'
1380
+ ' * crU = Correlation ratio (Unsymmetric)'
1381
+ ' * crM = Correlation ratio (symmetrized by Multiplication)'
1382
+ ' * crA = Correlation ratio (symmetrized by Addition)'
1383
+ ' * L2slope = slope of least-squares (L2) linear regression of '
1384
+ ' the data from dataset1 vs. the dataset2 '
1385
+ ' (i.e., d2 = a + b*d1 ==> this is \' b\' )'
1386
+ ' * L1slope = slope of least-absolute-sum (L1) linear '
1387
+ ' regression of the data from dataset1 vs. '
1388
+ ' the dataset2'
1389
+ ' * num = number of the values in the region: '
1390
+ ' with the use of -mask or -automask, '
1391
+ ' the size of the region around any given '
1392
+ ' voxel will vary; this option lets you '
1393
+ ' map that size.'
1394
+ ' * ALL = all of the above, in that order'
1395
+ 'More than one option can be used.' ,
1396
+ argstr = '-stat %s...' )
1397
+ mask_file = traits .File (
1398
+ exists = True ,
1399
+ desc = 'mask image file name. Voxels NOT in the mask will not be used '
1400
+ 'in the neighborhood of any voxel. Also, a voxel NOT in the mask '
1401
+ 'will have its statistic(s) computed as zero (0).' ,
1402
+ argstr = '-mask %s' )
1403
+ automask = traits .Bool (
1404
+ desc = 'Compute the mask as in program 3dAutomask.' ,
1405
+ argstr = '-automask' ,
1406
+ xor = ['weight_file' ])
1407
+ weight_file = traits .File (
1408
+ exists = True ,
1409
+ desc = 'File name of an image to use as a weight. Only applies to '
1410
+ '\' pearson\' statistics.' ,
1411
+ argstr = '-weight %s' ,
1412
+ xor = ['automask' ])
1413
+ out_file = traits .File (
1414
+ desc = 'Output dataset.' ,
1415
+ argstr = '-prefix %s' ,
1416
+ name_source = 'in_file1' ,
1417
+ name_template = '%s_bistat' ,
1418
+ keep_extension = True ,
1419
+ position = 0 )
1420
+
1421
+
1422
+ class LocalBistat (AFNICommand ):
1423
+ """3dLocalBistat - computes statistics between 2 datasets, at each voxel,
1424
+ based on a local neighborhood of that voxel.
1425
+
1426
+ For complete details, see the `3dLocalBistat Documentation.
1427
+ <https://afni.nimh.nih.gov/pub../pub/dist/doc/program_help/3dLocalBistat.html>`_
1428
+
1429
+ Examples
1430
+ ========
1431
+
1432
+ >>> from nipype.interfaces import afni
1433
+ >>> bistat = afni.LocalBistat()
1434
+ >>> bistat.inputs.in_file1 = 'functional.nii'
1435
+ >>> bistat.inputs.in_file2 = 'structural.nii'
1436
+ >>> bistat.inputs.neighborhood = ('SPHERE', 1.2)
1437
+ >>> bistat.inputs.stat = 'pearson'
1438
+ >>> bistat.inputs.outputtype = 'NIFTI'
1439
+ >>> bistat.cmdline
1440
+ "3dLocalBistat -prefix functional_bistat.nii -nbhd 'SPHERE(1.2)' -stat pearson functional.nii structural.nii"
1441
+ >>> res = automask.run() # doctest: +SKIP
1442
+
1443
+ """
1444
+
1445
+ _cmd = '3dLocalBistat'
1446
+ input_spec = LocalBistatInputSpec
1447
+ output_spec = AFNICommandOutputSpec
1448
+
1449
+ def _format_arg (self , name , spec , value ):
1450
+ if name == 'neighborhood' and value [0 ] == 'RECT' :
1451
+ value = ('RECT' , '%s,%s,%s' % value [1 ])
1452
+
1453
+ return super (LocalBistat , self )._format_arg (name , spec , value )
1454
+
1455
+
1341
1456
class MaskToolInputSpec (AFNICommandInputSpec ):
1342
1457
in_file = File (
1343
1458
desc = 'input file or files to 3dmask_tool' ,
0 commit comments