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

Issues with running the tests for this code #198

Open
ppetrecca opened this issue Aug 9, 2024 · 12 comments
Open

Issues with running the tests for this code #198

ppetrecca opened this issue Aug 9, 2024 · 12 comments

Comments

@ppetrecca
Copy link

Greetings. I am not an expert in matters julia, and this is the first code I've tried ever tried to use. I have found several problems.

  • Do I really have to premise "using xxx" several times every time I open julia? Just for the tests, it's using PyPlot, using MRIReco, using FFTW, using NFFT, using HTTP...
  • The ExamplesRadial.jl, after using MRISimulations and ImageUtils still wants another varname ("L2Regularization" and "L1Regularization") and I have no idea as to what those mean and where to get them
  • The ../examples/mridataorg/example.jl straight-up kicks me out of julia due to an EXCEPTION_ACCESS_VIOLATION

Any help would be greatly appreciated.

@nHackel
Copy link
Member

nHackel commented Aug 9, 2024

Hello,

to fix the issue with L2 and L1 you can add using MRIReco.RegularizedLeastSquares for now. In a future release we'll make this more seamless.

Could you link me the example or paste the exact code that causes the issue with L2Regularization? The example I found doesn't seem to have any user-defined regularization.

It is possible to configure Julia to always load certain packages when starting, this is usually done by adding them in the ~/.julia/config/startup.jl file. However, that is often done for packages that make developing code or using the REPL easier and not specific like MRIReco.jl.

MRIReco.jl itself does not require the user to add PyPlot, HTTP and co., all dependencies it needs are already included. It's just when the examples need to plot something, this is the package that was used to do that

@ppetrecca
Copy link
Author

Thanks for your answer. However, when I run the very example you're suggesting, julia tells me that shepp_logan is not defined, and once I add the package for the Shepp-Logan, it goes on to tell me that simulation is not defined, forcing me to add the next package, and so on. Clearly, I am missing something evident.

@nHackel
Copy link
Member

nHackel commented Aug 16, 2024

I just linked the example to know where the L2 issue came from because I don't see it being used in the example.

The example is outdated and not executable directly without adding those packages. The example isn't part of the tests for the package nor the documentation.

Under docs/lit/examples you can see the code that created the examples shown in the documentation. Those are examplles that are actively run in the build process and produce documents pages. But they are also executable Julia scripts

@ppetrecca
Copy link
Author

I apologize, but I still don't get it. The examples in \docs\src\examples are outdated? Is that why, after installing the packages manually for exampleIO and trying to use it to open a Bruker scan it tells me "ArgumentError: input string is empty or only contains whitespace", or is that a different problem altogether? Are you saying the examples in \docs\lit\examples are up to date? Because I have the same problem running those (well, almost, the missing package is "CairoMakie" in those). As I said before, I'm a beginner here, so this might be all on me, a 3D UTE scan was dropped on me, I have no idea where to start with the reconstruction, and I hoped this package would help.

Thank you for taking the time to answer!

@aTrotier
Copy link
Contributor

For your error it seems the path is wrong.
For the 3D UTE scan, if the sequence has been acquired under PV6.0.1 (maybe also PV6) it should work. For PV360-X.X I did not take the time to wrote it (No one asked for it :) )

Some of the example are outdated it is better to take a look at the test. You can find the one for the bruker 3DUTE here :

# Reconstruction of 3DUTE

@nHackel is finalizing an important PR, after that I will take a look to update the documentation.

@nHackel
Copy link
Member

nHackel commented Aug 16, 2024

Okay, so when I say outdated, I mean that they haven't been manually looked at and run for a while, unlike the example in the /lit/ folder. Those were run to produce for example this page in the documentation. I've linked to the section detailing the reproducability information of that specific example.

The other examples should still work, when started in the proper Julia session, i.e. in a session where also PyPlot, RegularizedLeastSquares and co. are loaded. Whatever packages are needed depend on the example in question.

It is a bit difficult to help you, because we can't reproduce the code that you are running, which is why I asked about which example you ran where you had the L2Regularization error. The only version of ExamplesRadial.jl that I found didn't include an L2Regularization term from what I could see.

Ideally, you tell us exactly the example you ran and then post the errors with stacktraces, otherwise we can neither reproduce nor make an educated guess what the issue.

For example the /lit/examples all have using CairoMakie at the start, so from what I can tell, those shouldn't fail because the script doesn't know CairoMakie.

If you mean that you had to add CairoMakie before running that example, then that is normal and outside of the scope of the script. Usually, newer Julia versions just ask you if you want to install a packge that you are trying to use, but haven't installed yet.

@nHackel
Copy link
Member

nHackel commented Aug 16, 2024

Ah @aTrotier also replied. That's good because I'm not super versed in MRI itselfs and mostly focused on the optimization backend of the package (which is where the L2Regularization is relevant).

The important PR has actually been released @aTrotier, we now have GPU support 🎉 Maybe in a seperate issue we can discuss how we want to update the documentation and leave this for helping @ppetrecca

@ppetrecca
Copy link
Author

Thank you both for your answers. I will try to be clearer in the following.
Regarding the examples you proposed, those in /lit/examples/, I tried running them. I did so using the code
using PyPlot
using MRIReco
using CairoMakie
using MRIReco.RegularizedLeastSquares
include("exampleName.jl")
after opening a command window in /lit/examples/. I still get warnings. My "code" is completely bare, I only added all packages that I felt might be useful, and I ran the example. "01-binning" works fine (I think), but 02 already gives problems, since the ifftshift is not defined apparently, but if apart from that, if I cancel the two lines where it's written, it gives no errors. "03-subspaceReconstruction.jl" on the other hand STILL gives me problems regarding the L2Regularization, despite me adding "using MRIReco.RegularizedLeastSquares". Here's the complete warning:
julia> include("03-subspaceReconstruction.jl")
ERROR: LoadError: UndefVarError: L2Regularization not defined
Stacktrace:
[1] top-level scope
@ C:\Users\Erran\Downloads\MRIReco.jl-master\docs\lit\examples\03-subspaceReconstruction.jl:90
[2] include(fname::String)
@ Base.MainInclude .\client.jl:489
[3] top-level scope
@ REPL[12]:1
in expression starting at C:\Users\Erran\Downloads\MRIReco.jl-master\docs\lit\examples\03-subspaceReconstruction.jl:90

I also tried running "testBrukerFile.jl". I also ONLY added "using xxx" for the packages that seemes useful and include("testBrukerFile.jl"). That one also wants L1Regularization:
julia> include("testBrukerFile.jl")
┌ Info: Read parameters timing
│ t1 = 0.0020097
└ t2 = 6.0e-7
┌ Warning: 1st half of image are the REAL part and 2nd half is the imaginary
└ @ MRIFiles C:\Users\Erran.julia\packages\MRIFiles\9hXgx\src\Bruker\Bruker.jl:424
[ Info: Bruker protocol name : T2_RARE
[ Info: Bruker protocol name : FLASH
[ Info: Bruker protocol name : FLASH
[ Info: Bruker protocol name : FLASH
[ Info: read offset not performed (only phase + slice)
BrukerFile Reco: Error During Test at C:\Users\Erran\Downloads\MRIReco.jl-master\MRIFiles\test\testBrukerFile.jl:46
Got exception outside of a @test
UndefVarError: L1Regularization not defined
Stacktrace:
[1] macro expansion
@ C:\Users\Erran\Downloads\MRIReco.jl-master\MRIFiles\test\testBrukerFile.jl:101 [inlined]
[2] macro expansion
@ C:\Users\Erran.julia\juliaup\julia-1.10.5+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Test\src\Test.jl:1577 [inlined]
[3] macro expansion
@ C:\Users\Erran\Downloads\MRIReco.jl-master\MRIFiles\test\testBrukerFile.jl:47 [inlined]
[4] macro expansion
@ C:\Users\Erran.julia\juliaup\julia-1.10.5+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Test\src\Test.jl:1577 [inlined]
[5] top-level scope
@ C:\Users\Erran\Downloads\MRIReco.jl-master\MRIFiles\test\testBrukerFile.jl:3
[6] include(fname::String)
@ Base.MainInclude .\client.jl:489
[7] top-level scope
@ REPL[11]:1
[8] eval
@ .\boot.jl:385 [inlined]
[9] eval_user_input(ast::Any, backend::REPL.REPLBackend, mod::Module)
@ REPL C:\Users\Erran.julia\juliaup\julia-1.10.5+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:150
[10] repl_backend_loop(backend::REPL.REPLBackend, get_module::Function)
@ REPL C:\Users\Erran.julia\juliaup\julia-1.10.5+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:246
[11] start_repl_backend(backend::REPL.REPLBackend, consumer::Any; get_module::Function)
@ REPL C:\Users\Erran.julia\juliaup\julia-1.10.5+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:231
[12] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool, backend::Any)
@ REPL C:\Users\Erran.julia\juliaup\julia-1.10.5+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:389
[13] run_repl(repl::REPL.AbstractREPL, consumer::Any)
@ REPL C:\Users\Erran.julia\juliaup\julia-1.10.5+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:375
[14] (::Base.var"#1013#1015"{Bool, Bool, Bool})(REPL::Module)
@ Base .\client.jl:432
[15] #invokelatest#2
@ .\essentials.jl:892 [inlined]
[16] invokelatest
@ .\essentials.jl:889 [inlined]
[17] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
@ Base .\client.jl:416
[18] exec_options(opts::Base.JLOptions)
@ Base .\client.jl:333
[19] _start()
@ Base .\client.jl:552
Test Summary: | Pass Error Total Time
BrukerFile | 15 1 16 7.9s
BrukerFile read parameters | 7 7 0.0s
BrukerFile read 2dseq | 3 3 0.0s
BrukerFile Reco | 5 1 6 7.8s
ERROR: LoadError: Some tests did not pass: 15 passed, 0 failed, 1 errored, 0 broken.
in expression starting at C:\Users\Erran\Downloads\MRIReco.jl-master\MRIFiles\test\testBrukerFile.jl:1

I don't even know whether I need the parts of the code that require L1 and L2 regularization, since I only need to interpret a 3D UTE Bruker file, but I can't seem to get these tests to work. Thank you for your patience.

@aTrotier
Copy link
Contributor

aTrotier commented Sep 10, 2024

Sorry I am on parental leave right now and can't completely debug your issue.

One remark, I think the way to use the literal example is to activate the environment in the docs folder and then you can run the literate example from their.

If you don't need the advanced parallel or compressed sensing reconstruction (which causes issue with L1 /L2 régularisation term. And use the "direct" reconstruction.

I did not had time to change the literate example.

@ppetrecca
Copy link
Author

I understand. Thank you for the attempt, however, running the exaples from the docs folder changed nothing. I wish you a relaxing parental leave.

@aTrotier
Copy link
Contributor

@ppetrecca we still have a conflict when Pkg.instantiate() is called for the docs/folder but if you activate the docs environment and dev MRISimulation#master I think you should be able to run the literate example

@aTrotier
Copy link
Contributor

@ppetrecca now it should works :)

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