-
Notifications
You must be signed in to change notification settings - Fork 21
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
Custom values for brain_phantom #484
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #484 +/- ##
==========================================
- Coverage 90.77% 86.69% -4.08%
==========================================
Files 54 54
Lines 3002 2991 -11
==========================================
- Hits 2725 2593 -132
- Misses 277 398 +121
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I think this is a good idea, but how this is implemented adds too many lines and complexity (you repeat the same code twice). That is why the code coverage fails, as your not adding a test for the other if branch. I would suggest having default values in If the user specifies I think this could be done without adding so many lines. |
Changing from `custom_values` to `tissue_properties`
What do you think about it now? I removed those lines. |
I think the default properties could do something similar to the simulation parameters, and have a default_brain_tissue_properties function. And the user defined parameters are merged to that. As it doesn't make sense to be defined twice (one in 2d and one in 3d). Also it makes more sense that the keys for the dictionary were the tissue names, and that inside you can specify the per tissue properties in some documented order. As the other way around the user needs to remember which tissue was which and it's prone to errors. It will be more verbose but easier to understand, and enable to modify just some tissues. |
Including magnetization states for storing purposes in phantom
Sorry about those last commits, the last one is the good one. In summary, I wrote a |
It looks a lot better now! |
Ok I had to merge another branch before and now this has merge conflicts. Could you solved them so I can merge this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Apply these last minor suggestions, and I will merge them (some spaces and new lines are being added).
Co-authored-by: Carlos Castillo Passi <cncastillo@uc.cl>
Co-authored-by: Carlos Castillo Passi <cncastillo@uc.cl>
Co-authored-by: Carlos Castillo Passi <cncastillo@uc.cl>
Co-authored-by: Carlos Castillo Passi <cncastillo@uc.cl>
Co-authored-by: Carlos Castillo Passi <cncastillo@uc.cl>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized that some parts of the code were not completely ok. They are also minor.
default_properties = Dict( | ||
# T1, T2, T2*, ρ, Δw | ||
"CSF" => [2.569, 0.329, 0.058, 1, 0], | ||
"GM" => [0.833, 0.083, 0.069, 0.86, 0], | ||
"WM" => [0.500, 0.070, 0.061, 0.77, 0], | ||
"FAT1" => [0.350, 0.070, 0.058, 1, -3.84], #-220 Hz | ||
"MUSCLE" => [0.900, 0.047, 0.030, 1, 0], | ||
"SKIN/MUSCLE" => [0.569, 0.329, 0.058, 1, 0], | ||
"SKULL" => [0, 0, 0, 0, 0], | ||
"VESSELS" => [0, 0, 0, 0, 0], | ||
"FAT2" => [0.500, 0.070, 0.061, 0.77, -3.84], #-220 Hz | ||
"DURA" => [2.569, 0.329, 0.058, 1, 0], | ||
"MARROW" => [0.500, 0.070, 0.061, 0.77, 0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve indentation, and reorder properties (not done here):
default_properties = Dict( | |
# T1, T2, T2*, ρ, Δw | |
"CSF" => [2.569, 0.329, 0.058, 1, 0], | |
"GM" => [0.833, 0.083, 0.069, 0.86, 0], | |
"WM" => [0.500, 0.070, 0.061, 0.77, 0], | |
"FAT1" => [0.350, 0.070, 0.058, 1, -3.84], #-220 Hz | |
"MUSCLE" => [0.900, 0.047, 0.030, 1, 0], | |
"SKIN/MUSCLE" => [0.569, 0.329, 0.058, 1, 0], | |
"SKULL" => [0, 0, 0, 0, 0], | |
"VESSELS" => [0, 0, 0, 0, 0], | |
"FAT2" => [0.500, 0.070, 0.061, 0.77, -3.84], #-220 Hz | |
"DURA" => [2.569, 0.329, 0.058, 1, 0], | |
"MARROW" => [0.500, 0.070, 0.061, 0.77, 0]) | |
default_properties = Dict( | |
# T1 T2 T2* ρ Δw | |
"CSF" => [2.569, 0.329, 0.058, 1, 0], | |
"GM" => [0.833, 0.083, 0.069, 0.86, 0], | |
"WM" => [0.500, 0.070, 0.061, 0.77, 0], | |
"FAT1" => [0.350, 0.070, 0.058, 1, -3.84], # -220 Hz | |
"MUSCLE" => [0.900, 0.047, 0.030, 1, 0], | |
"SKIN/MUSCLE" => [0.569, 0.329, 0.058, 1, 0], | |
"SKULL" => [0, 0, 0, 0, 0], | |
"VESSELS" => [0, 0, 0, 0, 0], | |
"FAT2" => [0.500, 0.070, 0.061, 0.77, -3.84], # -220 Hz | |
"DURA" => [2.569, 0.329, 0.058, 1, 0], | |
"MARROW" => [0.500, 0.070, 0.061, 0.77, 0] | |
) |
for i=1:5 | ||
temp = | ||
(labels .== 23) * tissue_properties["CSF"][i] .+ #CSF | ||
(labels .== 46) * tissue_properties["GM"][i] .+ #GM | ||
(labels .== 70) * tissue_properties["WM"][i] .+ #WM | ||
(labels .== 93) * tissue_properties["FAT1"][i] .+ #FAT1 | ||
(labels .== 116) * tissue_properties["MUSCLE"][i] .+ #MUSCLE | ||
(labels .== 139) * tissue_properties["SKIN/MUSCLE"][i] .+ #SKIN/MUSCLE | ||
(labels .== 162) * tissue_properties["SKULL"][i] .+ #SKULL | ||
(labels .== 185) * tissue_properties["VESSELS"][i] .+ #VESSELS | ||
(labels .== 209) * tissue_properties["FAT2"][i] .+ #FAT2 | ||
(labels .== 232) * tissue_properties["DURA"][i] .+ #DURA | ||
(labels .== 255) * tissue_properties["MARROW"][i] #MARROW | ||
push!(properties, temp) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized this is iterating for (T1, T2, T2*, ρ, Δw) instead of the tissue properties. This code has many problems:
- for loop is hard-coded to
i = 1:5
, what is 5? what if we want more properties? if we change it to 6 it will error. - the properties are not preallocated, you
push!
them. - The order of the properties does not make much sense. T1 and T2 before ρ?
- The Δw = -3.84 doesn't seem correct.
Suggestion:
Nproperties = 5 # ρ, T1, T2, T2*, Δw, explicit ... 5 is the number of properties
# or
Nproperties = size(tissue_properties ... , 2) # Or something like that
properties = zeros(size(...), Nproperties)
tissue_labels = [23, 46, ....]
for (label, tissue) in zip(tissue_labels, tissue_properties)
for property in 1:Nproperties
properties[:,:, property] .+= (labels .== label) .* tissue[property]
end
end
It would be useful to be able to change the default values. For example, when dealing with T1 or T2 changes due to different magnetic field strengths.
The changes on
brain_phantom2D
andbrain_phantom3D
allow the user to define the desired values if passed as an argument.