Skip to content
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

Multi_io axis out of bounds error #1568

Closed
aarya22 opened this issue Jun 15, 2018 · 4 comments
Closed

Multi_io axis out of bounds error #1568

aarya22 opened this issue Jun 15, 2018 · 4 comments

Comments

@aarya22
Copy link
Contributor

aarya22 commented Jun 15, 2018

When running any of the workflows in reconst.py for the associated Brain-Life app, the following error is produced when trying to use the multi_io iterator.

Traceback (most recent call last):
File "/usr/local/bin/dipy_fit_csa", line 9, in <module>
    run_flow(ReconstCSAFlow())
File "/usr/local/lib/python2.7/dist-packages/dipy/workflows/flow_runner.py", line 82, in run_flow
    return flow.run(**args)
File "/usr/local/lib/python2.7/dist-packages/dipy/workflows/reconst.py", line 661, in run
    opeaks_values, opeaks_indices, ogfa) in io_it:
File "/usr/local/lib/python2.7/dist-packages/dipy/workflows/multi_io.py", line 253, in __iter__
    IO = np.concatenate([I, O], axis=1)
numpy.core._internal.AxisError: axis 1 is out of bounds for array of dimension 1

This seems to be related to the _iter function for IOIterator in multi_io.py. A possible fix may be to use the np.vstack function instead of np.concatenate with axis=1.

Ex

import numpy as np
t1 = np.arange(1,10)
t2 = np.arange(11,20)
t3 = np.concatenate((t1,t2), axis=1)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
numpy.core._internal.AxisError: axis 1 is out of bounds for array of dimension 1
import numpy as np
t1 = np.arange(1,10)
t2 = np.arange(11,20)
t3 = np.vstack((t1,t2))

t3
array([[ 1,  2,  3,  4,  5,  6,  7,  8,  9],
       [11, 12, 13, 14, 15, 16, 17, 18, 19]])
@skoudoro
Copy link
Member

Looks like you are missing the mask in your command line @Aarya. The mask file is mandatory. If it is the case, we should improve the error message.

Can you test this case @parichit? (How IOIterator react when a positional parameter is missing)

@parichit
Copy link
Contributor

@skoudoro: Thank for letting me know. I myself got into this issue where I specified the positional argument in the run method and the doc string but did not specify it on the command line when running the workflow (I was testing the apply transform workflow for image registration) and the error message is the following:

File "/Users/schmuck/.local/bin/dipy_transform_affine", line 6, in
exec(compile(open(file).read(), file, 'exec'))
File "/Users/schmuck/Documents/Box Sync/dipy/bin/dipy_transform_affine", line 7, in
run_flow(ApplyTransformFlow())
File "/Users/schmuck/Documents/Box Sync/dipy/dipy/workflows/flow_runner.py", line 55, in run_flow
args = parser.get_flow_args()
File "/Users/schmuck/Documents/Box Sync/dipy/dipy/workflows/base.py", line 281, in get_flow_args
ns_args = self.parse_args(args, namespace)
File "/Users/schmuck/Documents/Box Sync/dipy/dipy/fixes/argparse.py", line 1667, in parse_args
args, argv = self.parse_known_args(args, namespace)
File "/Users/schmuck/Documents/Box Sync/dipy/dipy/fixes/argparse.py", line 1699, in parse_known_args
return self.parse_known_args(args, namespace)
File "/Users/schmuck/Documents/Box Sync/dipy/dipy/fixes/argparse.py", line 1912, in parse_known_args
self.error(
('too few arguments'))
UnboundLocalError: local variable '
' referenced before assignment

You can see it says that 'Too few argument' but I agree with you, it is not very clear for the end user.

I will put a more user friendly message.

Thanks :)

@parichit
Copy link
Contributor

@skoudoro: Should I create a separate PR for this issue? I can replace the error message with a more detailed one. On the other hand, I am not sure if this is the problem that @aarya22 is having.

@aarya22: Can you please share the command line that you used to run the workflow.

@skoudoro
Copy link
Member

skoudoro commented Sep 7, 2018

message fixed by #1554. closing

@skoudoro skoudoro closed this as completed Sep 7, 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

No branches or pull requests

3 participants