neuronets / kwyk

Knowing what you know - Bayesian brain parcellation
https://doi.org/10.3389/fninf.2019.00067
Apache License 2.0
20 stars 9 forks source link

[Issue] mri_convert.bin: can't determine type of output volume #9

Closed PeerHerholz closed 5 years ago

PeerHerholz commented 5 years ago

Ahoi hoi,

I'm currently testing the network a bit and received an error upon saving the output files.

I did run the docker option as follows:

docker run -it --rm -v /Users/peerherholz/Desktop/:/data neuronets/kwyk:latest-cpu -m bvwn_multi_prior --save-entropy sub-01_T1w.nii output

It took 52 min. on an i5, 16 GB MacBook Pro with docker having access to 2 CPUs, 10 GB and 1 GB swap. Everything works as expected, except for the last step(s), that is file saving. Here, I receive the following error:

64/64 [==============================] - 3392s 53s/step
++ Saving results.
/opt/nobrainer/third_party/freesurfer/bin/mri_convert: line 2: /opt/nobrainer/third_party/freesurfer/sources.sh: No such file or directory
mri_convert.bin -rl sub-01_T1w.nii -rt nearest -ns 1 output_means output_means_orig
mri_convert.bin: can't determine type of output volume
Traceback (most recent call last):
  File "/usr/local/bin/nobrainer_bwn", line 11, in <module>
    load_entry_point('nobrainer', 'console_scripts', 'nobrainer_bwn')()
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/opt/nobrainer/nobrainer/cli_click.py", line 106, in predict
    _reslice(outfile_means, outfile_means_orig, _orig_infile, True)
  File "/opt/nobrainer/nobrainer/cli_click.py", line 125, in _reslice
    check=True)
  File "/usr/lib/python3.5/subprocess.py", line 398, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['mri_convert', '-rl', 'sub-01_T1w.nii', '-rt', 'nearest', '-ns', '1', 'output_means', 'output_means_orig']' returned non-zero exit status 1

However, I do get one output which is the output_means.nii image that looks reasonably well:

Screen Shot 2019-08-23 at 9 24 24 AM Screen Shot 2019-08-23 at 9 24 29 AM Screen Shot 2019-08-23 at 9 24 34 AM

Any idea on how to tackle this? It looks like some FreeSurfer resources, sources.sh, are missing:

/opt/nobrainer/third_party/freesurfer/bin/mri_convert: line 2: /opt/nobrainer/third_party/freesurfer/sources.sh: No such file or directory

Would be great to hear from you.

Cheers, peer

kaczmarj commented 5 years ago

Ahoi hoi @PeerHerholz - i will look into this. the missing sources.sh might not be the main cause.

satra commented 5 years ago

it's very likely my fault related to the prefix changes. output_means and output_means_orig should both have the suffix for extension. this is in cli_click.py.

@kaczmarj - if you are up for it, i would also like to refactor kwyk a bit as having nobrainer as a submodule rather than extending it.

kaczmarj commented 5 years ago

@PeerHerholz - looks like this issue is fixed. please re-open if you run into it again. thanks for catching it.

PeerHerholz commented 5 years ago

@kaczmarj - coolio, thx for the fix. I'll try it asap.

kaczmarj commented 5 years ago

thanks. let me know because i'm not sure it has been fixed... i couldn't reproduce it with an .nii.gz file.

PeerHerholz commented 5 years ago

aaaaand here we go again, sorry! I just tried it again last night, using the same docker command as before, this time providing a .nii.gz:

docker run -it --rm -v /Users/peerherholz/Desktop/:/data neuronets/kwyk:latest-cpu -m bvwn_multi_prior --save-entropy sub-01_T1w.nii.gz output

However, I got the same error:

++ Saving results.
/opt/nobrainer/third_party/freesurfer/bin/mri_convert: line 2: /opt/nobrainer/third_party/freesurfer/sources.sh: No such file or directory
mri_convert.bin -rl sub-01_T1w.nii.gz -rt nearest -ns 1 output_means output_means_orig
mri_convert.bin: can't determine type of output volume
Traceback (most recent call last):
  File "/usr/local/bin/nobrainer_bwn", line 11, in <module>
    load_entry_point('nobrainer', 'console_scripts', 'nobrainer_bwn')()
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/opt/nobrainer/nobrainer/cli_click.py", line 106, in predict
    _reslice(outfile_means, outfile_means_orig, _orig_infile, True)
  File "/opt/nobrainer/nobrainer/cli_click.py", line 125, in _reslice
    check=True)
  File "/usr/lib/python3.5/subprocess.py", line 398, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['mri_convert', '-rl', 'sub-01_T1w.nii.gz', '-rt', 'nearest', '-ns', '1', 'output_means', 'output_means_orig']' returned non-zero exit status 1

Then I recognized, that I wasn't using the latest version of the docker image which isn't latest-cpu, but master-cpu. Using that, everything seems to work fine, despite the /opt/kwyk/freesurfer/bin/mri_convert: line 2: /opt/kwyk/freesurfer/sources.sh: No such file or directory

still being present.

I get output_means.nii.gz, output_means_orig.nii.gz, output_entropy.nii.gz and output_entropy_orig.nii.gz and they look reasonably well.

As the readme points to latest-cpu, the respective part or the corresponding docker tag could/should maybe be adapted!?

satra commented 5 years ago

we should do an updated release, since this is an issue that is likely to affect other people. but the readme still should say latest, but we can include in the readme a description of docker tags.

master == master repo on github
latest == last released version
kaczmarj commented 5 years ago

thanks @PeerHerholz.

@satra - i agree. i think we can adopt something similar to tensorflow's docker tag schema:

VERSION[-gpu]

so we would have

satra commented 5 years ago

@kaczmarj - it's already that except cpu and gpu are explicitly defined.

satra commented 5 years ago

i've released 0.3 with the fixes.