|
25 | 25 | CommandLineInputSpec, CommandLine, Directory, TraitedSpec,
|
26 | 26 | traits, isdefined, File, InputMultiPath, Undefined, Str)
|
27 | 27 | from ...external.due import BibTeX
|
28 |
| - |
| 28 | +from distutils import spawn |
29 | 29 | from .base import (
|
30 | 30 | AFNICommandBase, AFNICommand, AFNICommandInputSpec, AFNICommandOutputSpec)
|
31 | 31 |
|
@@ -1494,6 +1494,94 @@ class NwarpApply(AFNICommandBase):
|
1494 | 1494 | input_spec = NwarpApplyInputSpec
|
1495 | 1495 | output_spec = AFNICommandOutputSpec
|
1496 | 1496 |
|
| 1497 | +class OneDToolPyInputSpec(AFNICommandInputSpec): |
| 1498 | + in_file = File( |
| 1499 | + desc='input file to OneDTool', |
| 1500 | + argstr='-infile %s', |
| 1501 | + mandatory=True, |
| 1502 | + exists=True) |
| 1503 | + py27_path = File( |
| 1504 | + desc='Path to Python 2.7 executable for running afni python scripts', |
| 1505 | + argstr='%s '+spawn.find_executable('1d_tool.py'), |
| 1506 | + exists=True, |
| 1507 | + default='/opt/miniconda/envs/py27/bin/python', |
| 1508 | + usedefault=True, |
| 1509 | + position=0 |
| 1510 | + ) |
| 1511 | + set_nruns = traits.Int( |
| 1512 | + desc='treat the input data as if it has nruns', |
| 1513 | + argstr='-set_nruns %d') |
| 1514 | + derivative = traits.Bool( |
| 1515 | + desc='take the temporal derivative of each vector (done as first backward difference)', |
| 1516 | + argstr='-derivative') |
| 1517 | + demean = traits.Bool( |
| 1518 | + desc='demean each run (new mean of each run = 0.0)', |
| 1519 | + argstr='-demean') |
| 1520 | + out_file = File( |
| 1521 | + desc='write the current 1D data to FILE', |
| 1522 | + argstr='-write %s', |
| 1523 | + xor=['show_cormat_warnings']) |
| 1524 | + show_censor_count = traits.Bool( |
| 1525 | + desc='display the total number of censored TRs Note : if input is a valid xmat.1D dataset,' |
| 1526 | + 'then the count will come from the header. Otherwise the input is assumed to be a binary censor' |
| 1527 | + 'file, and zeros are simply counted.', |
| 1528 | + argstr="-show_censor_count") |
| 1529 | + censor_motion = traits.Tuple( |
| 1530 | + (traits.Float(),File()), |
| 1531 | + desc='Tuple of motion limit and outfile prefix. need to also set set_nruns -r set_run_lengths', |
| 1532 | + argstr="-censor_motion %f %s") |
| 1533 | + censor_prev_TR = traits.Bool( |
| 1534 | + desc='for each censored TR, also censor previous', |
| 1535 | + argstr='-censor_prev_TR') |
| 1536 | + show_trs_uncensored = traits.Enum('comma','space','encoded','verbose', |
| 1537 | + desc='display a list of TRs which were not censored in the specified style', |
| 1538 | + argstr='-show_trs_uncensored %s') |
| 1539 | + show_cormat_warnings = traits.File( |
| 1540 | + desc='Write cormat warnings to a file', |
| 1541 | + argstr="-show_cormat_warnings |& tee %s", |
| 1542 | + default="out.cormat_warn.txt", |
| 1543 | + usedefault=False, |
| 1544 | + position=-1, |
| 1545 | + xor=['out_file']) |
| 1546 | + show_indices_interest = traits.Bool( |
| 1547 | + desc="display column indices for regs of interest", |
| 1548 | + argstr="-show_indices_interest") |
| 1549 | + show_trs_run = traits.Int( |
| 1550 | + desc="restrict -show_trs_[un]censored to the given 1-based run", |
| 1551 | + argstr="-show_trs_run %d") |
| 1552 | + |
| 1553 | +class OneDToolPyOutputSpec(AFNICommandOutputSpec): |
| 1554 | + out_file = File(desc='output of 1D_tool.py') |
| 1555 | + |
| 1556 | +class OneDToolPy(AFNICommandBase): |
| 1557 | + """This program is meant to read/manipulate/write/diagnose 1D datasets. |
| 1558 | + Input can be specified using AFNI sub-brick[]/time{} selectors. |
| 1559 | +
|
| 1560 | + >>> from nipype.interfaces import afni |
| 1561 | + >>> odt = afni.OneDToolPy() |
| 1562 | + >>> odt.inputs.in_file = 'f1.1D' |
| 1563 | + >>> odt.inputs.py27_path = "/opt/miniconda/envs/py27/bin/python" |
| 1564 | + >>> odt.inputs.set_nruns = 3 |
| 1565 | + >>> odt.inputs.demean = True |
| 1566 | + >>> odt.inputs.out_file = 'motion_dmean.1D' |
| 1567 | + >>> odt.cmdline # doctest: +ALLOW_UNICODE |
| 1568 | + 'echo "" && /opt/miniconda/envs/py27/bin/python /root/abin/1d_tool.py -demean -infile f1.1D -write motion_dmean.1D -set_nruns 3' |
| 1569 | + >>> res = odt.run() # doctest: +SKIP |
| 1570 | +""" |
| 1571 | + |
| 1572 | + _cmd = 'echo "" && ' |
| 1573 | + |
| 1574 | + input_spec = OneDToolPyInputSpec |
| 1575 | + output_spec = OneDToolPyOutputSpec |
| 1576 | + |
| 1577 | + def _list_outputs(self): |
| 1578 | + outputs = self.output_spec().get() |
| 1579 | + |
| 1580 | + if isdefined(self.inputs.out_file): |
| 1581 | + outputs['out_file']=os.path.join(os.getcwd(), self.inputs.out_file) |
| 1582 | + if isdefined(self.inputs.show_cormat_warnings): |
| 1583 | + outputs['out_file']=os.path.join(os.getcwd(), self.inputs.show_cormat_warnings) |
| 1584 | + return outputs |
1497 | 1585 |
|
1498 | 1586 | class RefitInputSpec(CommandLineInputSpec):
|
1499 | 1587 | in_file = File(
|
|
0 commit comments