Skip to content

Commit

Permalink
Hwloc still being used in KomaUI #144
Browse files Browse the repository at this point in the history
  • Loading branch information
cncastillo committed Jan 5, 2023
1 parent 6132e9d commit f19b1e9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "KomaMRI"
uuid = "6a340f8b-2cdf-4c04-99be-4953d9b66d0a"
authors = ["Carlos Castillo Passi <[email protected]>"]
version = "0.7.2"
version = "0.7.3"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
38 changes: 0 additions & 38 deletions examples/3.koma_paper/comparison_speed/time_mean_std.m

This file was deleted.

34 changes: 19 additions & 15 deletions examples/CardiacLowFieldbSSFPSignal.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using KomaMRI
using KomaMRI, PlotlyJS
#Phantom
B0 = 0.55
fat_ppm = 3.4e-6
Expand All @@ -7,29 +7,25 @@ blood = Phantom{Float64}(x=[0], T1=[1200e-3],T2=[410e-3])
fat = Phantom{Float64}(x=[0], T1=[217e-3], T2=[95e-3], Δw=[-2π*γ*B0*fat_ppm])
obj = myocard+blood+fat
#Sequence parameters
TR = 5e-3 #5.81e-3
TR = 5.81e-3
TE = TR / 2 #bSSFP condition
RR = 1 #1 [s]
Trf = 1e-3 #1 [ms]
Tadc = 1e-3 #1 [ms]
Trf = 1e-4 #1 [ms]
B1 = 1 / (360*γ*Trf)
iNAV_lines = 14
im_segments = 20
first_flip_angle = 3.2
im_flip_angle = 90.
iNAV_flip_angle = 3.2
im_flip_angle = 90
number_heart_beats = 1

α = 10:10:180
M = zeros(ComplexF64, length(α), 3)
for (j, im_flip_angle) = enumerate(α)
#Sequence loop
function iNAV_bSSFP_cardiac(number_heart_beats, iNAV_lines, im_segments, iNAV_flip_angle, im_flip_angle)
k = 0
seq = Sequence()
for hb = 0 : number_heart_beats - 1
for i = 0 : iNAV_lines + im_segments - 1
if iNAV_lines != 0
m = (im_flip_angle - first_flip_angle) / iNAV_lines
α = min( m * i + first_flip_angle, im_flip_angle ) * exp(1im * π * k)
m = (im_flip_angle - iNAV_flip_angle) / iNAV_lines
α = min( m * i + iNAV_flip_angle, im_flip_angle ) * exp(1im * π * k)
else
α = im_flip_angle * exp(1im * π * k)
end
Expand All @@ -39,6 +35,14 @@ for (j, im_flip_angle) = enumerate(α)
end
seq += Delay(RR - TR * (iNAV_lines + im_segments))
end
return seq
end

αs = max.(1:10:180, iNAV_flip_angle)
M = zeros(ComplexF64, length(αs), 3)
for (j, im_flip_angle) = enumerate(αs)
#Sequence
seq = iNAV_bSSFP_cardiac(number_heart_beats, iNAV_lines, im_segments, iNAV_flip_angle, im_flip_angle)
#Simulation
sys = Scanner()
simParams = Dict{String,Any}("Nblocks"=>1, "return_type"=>"state")
Expand All @@ -47,9 +51,9 @@ for (j, im_flip_angle) = enumerate(α)
M[j,2] = aux.xy[2]
M[j,3] = aux.xy[3]
end
myo_plt = scatter(x=α, y=abs.(M[:,1]), name="Myocardium")
blo_plt = scatter(x=α, y=abs.(M[:,2]), name="Blood")
fat_plt = scatter(x=α, y=abs.(M[:,3]), name="Fat")
myo_plt = scatter(x=αs, y=abs.(M[:,1]), name="Myocardium")
blo_plt = scatter(x=αs, y=abs.(M[:,2]), name="Blood")
fat_plt = scatter(x=αs, y=abs.(M[:,3]), name="Fat")
plot([myo_plt, blo_plt, fat_plt], Layout(
title=attr(
text= "Optimal Flip Angle for bSSFP at 0.55T",
Expand Down
3 changes: 1 addition & 2 deletions src/KomaUI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ global kspace = [0.0im 0.; 0. 0.]
default = Dict{Symbol,Any}(:reco=>"direct") #, :iterations=>10, :λ=>1e-5,:solver=>"admm",:regularization=>"TV")
global recParams = merge(default, rec)
#Simulation
Ncores = Hwloc.num_physical_cores()
default = Dict{String,Any}("gpu"=>has_cuda(), "gpu_device"=>0, "Nthreads"=>has_cuda() ? 1 : Ncores)
default = Dict{String,Any}("gpu"=>has_cuda(), "gpu_device"=>0, "Nthreads"=>has_cuda() ? 1 : Threads.nthreads())
global simParams = merge(default, sim)
#GPUs
if simParams["gpu"]
Expand Down

0 comments on commit f19b1e9

Please sign in to comment.