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