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

juliaNotebookTest.ipynb unable to read task 9 spleen files #3

Closed
elbert5770 opened this issue Jul 21, 2022 · 4 comments
Closed

juliaNotebookTest.ipynb unable to read task 9 spleen files #3

elbert5770 opened this issue Jul 21, 2022 · 4 comments

Comments

@elbert5770
Copy link

With the correct paths to the task 9 data on Ubuntu 22.04

patientNum = 2
data_dir = "/home/elbert5770/Documents/julia/MRIimages/Task09_Spleen"
train_labels = map(fileEntry-> joinpath(data_dir,"labelsTr",fileEntry),readdir(joinpath(data_dir,"labelsTr"); sort=true))
train_images = map(fileEntry-> joinpath(data_dir,"imagesTr",fileEntry),readdir(joinpath(data_dir,"imagesTr"); sort=true))
zipped = collect(zip(train_images, train_labels))
tupl = zipped[patientNum]
targetSpacing = (1, 1, 1)
loaded = LoadFromMonai.loadBySitkromImageAndLabelPaths(tupl[1], tupl[2], targetSpacing)

gives the following error with Python 3.10.4 installed:

Python: RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute: /home/conda/feedstock_root/build_artifacts/libsimpleitk_1627514680097/work/Code/IO/src/sitkImageReaderBase.cxx:105:
sitk::ERROR: Unable to determine ImageIO reader for "/home/elbert5770/Documents/julia/MRIimages/Task09_Spleen/imagesTr/._spleen_12.nii.gz"

Stacktrace:
  [1] pythrow()
    @ PythonCall ~/.julia/packages/PythonCall/XgP8G/src/err.jl:94
  [2] errcheck
    @ ~/.julia/packages/PythonCall/XgP8G/src/err.jl:10 [inlined]
  [3] pycallargs
    @ ~/.julia/packages/PythonCall/XgP8G/src/abstract/object.jl:153 [inlined]
  [4] pycall(f::PythonCall.Py, args::String; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ PythonCall ~/.julia/packages/PythonCall/XgP8G/src/abstract/object.jl:171
  [5] pycall
    @ ~/.julia/packages/PythonCall/XgP8G/src/abstract/object.jl:161 [inlined]
  [6] #_#11
    @ ~/.julia/packages/PythonCall/XgP8G/src/Py.jl:360 [inlined]
  [7] Py
    @ ~/.julia/packages/PythonCall/XgP8G/src/Py.jl:360 [inlined]
  [8] loadBySitkromImageAndLabelPaths(imagePath::String, labelPath::String, targetSpacing::Tuple{Int64, Int64, Int64})
    @ MedPipe3D.LoadFromMonai ~/.julia/packages/MedPipe3D/NqvPg/src/fromMonai/LoadFromMonai.jl:123
  [9] top-level scope
    @ ~/Documents/julia/MRIimages/juliaNotebookTest.ipynb:21
 [10] eval
    @ ./boot.jl:373 [inlined]
 [11] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
...
    @ Base ./Base.jl:418
 [21] exec_options(opts::Base.JLOptions)
    @ Base ./client.jl:292
 [22] _start()
    @ Base ./client.jl:495

"name": "PythonCall.PyException",
	"message": "Python: RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute: /home/conda/feedstock_root/build_artifacts/libsimpleitk_1627514680097/work/Code/IO/src/sitkImageReaderBase.cxx:105:\nsitk::ERROR: Unable to determine ImageIO reader for \"/home/elbert5770/Documents/julia/MRIimages/Task09_Spleen/imagesTr/._spleen_12.nii.gz\"",
	"stack": "Python: RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute: /home/conda/feedstock_root/build_artifacts/libsimpleitk_1627514680097/work/Code/IO/src/sitkImageReaderBase.cxx:105:\nsitk::ERROR: Unable to determine ImageIO reader for \"/home/elbert5770/Documents/julia/MRIimages/Task09_Spleen/imagesTr/._spleen_12.nii.gz\"\n\nStacktrace:\n  [1] pythrow()\n    @ PythonCall ~/.julia/packages/PythonCall/XgP8G/src/err.jl:94\n  [2] errcheck\n    @ ~/.julia/packages/PythonCall/XgP8G/src/err.jl:10 [inlined]\n  [3] pycallargs\n    @ ~/.julia/packages/PythonCall/XgP8G/src/abstract/object.jl:153 [inlined]\n  [4] pycall(f::PythonCall.Py, args::String; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})\n    @ PythonCall ~/.julia/packages/PythonCall/XgP8G/src/abstract/object.jl:171\n  [5] pycall\n    @ ~/.julia/packages/PythonCall/XgP8G/src/abstract/object.jl:161 [inlined]\n  [6] #_#11\n    @ ~/.julia/packages/PythonCall/XgP8G/src/Py.jl:360 [inlined]\n  [7] Py\n    @ ~/.julia/packages/PythonCall/XgP8G/src/Py.jl:360 [inlined]\n  [8] loadBySitkromImageAndLabelPaths(imagePath::String, labelPath::String, targetSpacing::Tuple{Int64, Int64, Int64})\n    @ MedPipe3D.LoadFromMonai ~/.julia/packages/MedPipe3D/NqvPg/src/fromMonai/LoadFromMonai.jl:123\n  [9] top-level scope\n    @ ~/Documents/julia/MRIimages/juliaNotebookTest.ipynb:21\n [10] eval\n    @ ./boot.jl:373 [inlined]\n [11] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)\n    @ Base ./loading.jl:1196\n [12] #invokelatest#2\n    @ ./essentials.jl:716 [inlined]\n [13] invokelatest\n    @ ./essentials.jl:714 [inlined]\n [14] (::VSCodeServer.var\"#164#165\"{VSCodeServer.NotebookRunCellArguments, String})()\n    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.24/scripts/packages/VSCodeServer/src/serve_notebook.jl:19\n [15] withpath(f::VSCodeServer.var\"#164#165\"{VSCodeServer.NotebookRunCellArguments, String}, path::String)\n    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.24/scripts/packages/VSCodeServer/src/repl.jl:184\n [16] notebook_runcell_request(conn::VSCodeServer.JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, params::VSCodeServer.NotebookRunCellArguments)\n    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.24/scripts/packages/VSCodeServer/src/serve_notebook.jl:13\n [17] dispatch_msg(x::VSCodeServer.JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, dispatcher::VSCodeServer.JSONRPC.MsgDispatcher, msg::Dict{String, Any})\n    @ VSCodeServer.JSONRPC ~/.vscode/extensions/julialang.language-julia-1.6.24/scripts/packages/JSONRPC/src/typed.jl:67\n [18] serve_notebook(pipename::String, outputchannel_logger::Base.CoreLogging.SimpleLogger; crashreporting_pipename::String)\n    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.24/scripts/packages/VSCodeServer/src/serve_notebook.jl:136\n [19] top-level scope\n    @ ~/.vscode/extensions/julialang.language-julia-1.6.24/scripts/notebook/notebook.jl:32\n [20] include(mod::Module, _path::String)\n    @ Base ./Base.jl:418\n [21] exec_options(opts::Base.JLOptions)\n    @ Base ./client.jl:292\n [22] _start()\n    @ Base ./client.jl:495"

@elbert5770
Copy link
Author

elbert5770 commented Jul 21, 2022

CT-Org files work just fine as long as the label files are manually placed in a 'labels' folder and images are placed in a 'images' folder. Assuming you can download the CT-Org files (see issue 2).

@jakubMitura14
Copy link
Collaborator

jakubMitura14 commented Jul 22, 2022

Thanks for interest in my tools

Sometimes julia do not parse paths correctly
Try
zipped=map(tupl -> (replace(tupl[1], "." => ""), replace(tupl[2], "." => "")),zipped)

And generally check some path in array and compare it with true one, for reference, the methods that can be used

https://docs.julialang.org/en/v1/base/file/

@jakubMitura14
Copy link
Collaborator

Did it helped @elbert5770 :)?

@elbert5770
Copy link
Author

Yes, although the line in the original file is the correct one:
zipped=map(tupl -> (replace(tupl[1], "." => ""), replace(tupl[2], "." => "")),zipped)

It's just confusing because of all the hidden files in the directory. TBH, it would probably be better to ignore the hidden files rather than strip the ._

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

2 participants