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

Troubles defining Float32 or empty phantoms with KomaMRI 0.9 #498

Open
Tooine opened this issue Oct 16, 2024 · 1 comment · May be fixed by #499
Open

Troubles defining Float32 or empty phantoms with KomaMRI 0.9 #498

Tooine opened this issue Oct 16, 2024 · 1 comment · May be fixed by #499
Labels
bug Something isn't working

Comments

@Tooine
Copy link

Tooine commented Oct 16, 2024

What happened?

Hi,

I switched to KomaMRI 0.9 and observed some performance improvements with simulations, which is great 👍

Yet, I had some troubles (see below) with the way I define Float32 or empty phantoms with the new version.
I am not sure if this is a bug or just the new expected behavior since 0.9, as for both situations, I found a (imo, less esthetic) way to define it as I want.

Note that, if this is not a bug, there might be parts of the documentation to modify, like in the $T_2^*$ section of this page, where the following empty phantom definition does not work anymore (at least for me)

# (3.1.1) Create an empty phantom
obj_t2star = Phantom{Float64}(x=[])

Issue 1: Float32 vs Float64 phantom
Creating a phantom encoded in Float32 like this leads to an error

Phantom{Float32}(x=[1.0])
 ERROR: MethodError: Cannot `convert` an object of type NoMotion{Float64} to an object of type KomaMRIBase.AbstractMotion{Float32}

but this works fine and produces a phantom encoded in Float32 (including the motion!)

Phantom(x=Float32[1.0])
 Phantom{Float32}
  name: String "spins"
  x: Array{Float32}((1,)) Float32[1.0]
  y: Array{Float32}((1,)) Float32[0.0]
  z: Array{Float32}((1,)) Float32[0.0]
  ρ: Array{Float32}((1,)) Float32[1.0]
  T1: Array{Float32}((1,)) Float32[1.0f6]
  T2: Array{Float32}((1,)) Float32[1.0f6]
  T2s: Array{Float32}((1,)) Float32[1.0f6]
  Δw: Array{Float32}((1,)) Float32[0.0]
  Dλ1: Array{Float32}((1,)) Float32[0.0]
  Dλ2: Array{Float32}((1,)) Float32[0.0]
  Dθ: Array{Float32}((1,)) Float32[0.0]
  motion: NoMotion{Float32} NoMotion{Float32}()

Issue 2: Empty phantom
Those commands do not work anymore

Phantom(x=[])
Phantom{Float32}(x=[])
Phantom{Float64}(x=[])
 ERROR: MethodError: no method matching zero(::Type{Any})

But this works fine:

Phantom(x=Float32[])

Environment

OS x86_64-linux-gnu
Julia 1.10.2
KomaMRIPlots 0.9.0
KomaMRIFiles 0.9.0
KomaMRI 0.9.0
KomaMRICore 0.9.0
KomaMRIBase 0.9.0
@Tooine Tooine added the bug Something isn't working label Oct 16, 2024
@pvillacorta
Copy link
Collaborator

pvillacorta commented Oct 16, 2024

Thank you for posting this! This is indeed a bug, and is related to the new motion field in this new version.
See #499
Cheers

@pvillacorta pvillacorta linked a pull request Oct 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants