Skip to content

ENH: AFNI (3d)LocalBistat interface #2590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 24, 2018
Merged

Conversation

salma1601
Copy link
Contributor

try add interface for 3dLocalBistat

Copy link
Member

@effigies effigies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple issues with the input spec, and some suggestions on formatting.

@@ -1338,6 +1338,124 @@ def _list_outputs(self):
return outputs


class LocalBistatInputSpec(AFNICommandInputSpec):
in_files = InputMultiPath(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just be traits.List, not InputMultiPath.

And out of curiosity, is it more likely that people will want to pass in a list of two files or want separate names for each file (e.g. in_file1, in_file2)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be separate names are more suitable, you are right

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the plan to split this into two traits, or leave it as one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I forgot this, I am doing it

'jointent', 'hellinger', 'crU', 'crM', 'crA', 'L2slope',
'L1slope', 'num', 'ALL']
stat = traits.Either(
traits.Enum(*_stat_names), traits.List(traits.Enum(_stat_names)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this not work?

stat = traits.MultiPath(traits.Enum(_stat_names), ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I understand: traits does not seem to have a `MultiPath

AttributeError: 'module' object has no attribute 'MultiPath'`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry. I meant InputMultiPath, not traits.MultiPath. I don't know if I copy-pasted or actually wrote that out.

'\'SPHERE\', \'RHDD\' (rhombic dodecahedron), \'TOHD\' '
'(truncated octahedron) with a given radius in mm or '
'\'RECT\' (rectangular block) with dimensions to specify in mm.',
argstr='-nbhd %s')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

argstr='-nbhd %s(%s)'

Related to a comment below.

"'{0}({1})'".format(region_name, ','.join(region_size)))
else:
return spec.argstr % (
"'{0}({1})'".format(region_name, region_size))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the argstr='-nbhd %s(%s)' as suggested above, you could make this whole block:

if name == 'neighborhood' and value[0] == 'RECT':
    value = ('RECT', '%s,%s,%s' % value[1])

(Letting value fall through into the super call.)

desc='File name of an image to use as a weight. Only applies to '
'\'pearson\' statistics.',
argstr='-weight %s',
xor=['automask'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have two mask_file traits.

'will have its statistic(s) computed as zero (0).',
argstr='-mask %s')
automask = traits.Bool(
desc='Compute the mask as in program 3dAutomask.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be an argstr here?

if isinstance(value, (str, bytes)):
return spec.argstr % value
else:
return ' '.join([spec.argstr % v for v in value])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure you can drop this if name == 'stat' block and get the same behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure you can drop this if name == 'stat' block and get the same behavior.

this doesn't seem to work: it doesn't repeat the option '-stat' before each value

bistat.inputs.stat = ['pearson', 'ALL']

gives -stat pearson ALL instead of -stat pearson -stat ALL

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@salma1601 - if you change the argstr above to '-stat %s...' it will do what you are looking for.

@codecov-io
Copy link

codecov-io commented May 22, 2018

Codecov Report

Merging #2590 into master will increase coverage by 0.02%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2590      +/-   ##
=========================================
+ Coverage   67.57%   67.6%   +0.02%     
=========================================
  Files         335     336       +1     
  Lines       42630   42699      +69     
  Branches     5270    5278       +8     
=========================================
+ Hits        28807   28865      +58     
- Misses      13150   13157       +7     
- Partials      673     677       +4
Flag Coverage Δ
#smoketests 50.74% <ø> (ø) ⬆️
#unittests 65.06% <88.88%> (+0.03%) ⬆️
Impacted Files Coverage Δ
nipype/interfaces/afni/__init__.py 100% <ø> (ø) ⬆️
nipype/interfaces/afni/utils.py 81.75% <88.88%> (+0.19%) ⬆️
nipype/pipeline/plugins/multiproc.py 79.76% <0%> (-2.39%) ⬇️
nipype/interfaces/image.py 90.19% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb4d8b4...71fd6d3. Read the comment docs.

@effigies
Copy link
Member

Hi @salma1601, not to rush you, but just a heads up that we should try to get this in by Friday (EDT) if we want it in 1.0.4.

' map that size.'
' * ALL = all of the above, in that order'
'More than one option can be used.',
argstr='-stat %s')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try '-stat %s...'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it works, thanks !

@effigies effigies added this to the 1.0.4 milestone May 24, 2018
@effigies effigies changed the title add AFNI interface LocalBistat ENH: AFNI (3d)LocalBistat interface May 24, 2018
@effigies effigies merged commit 67d2657 into nipy:master May 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants