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

Write Pulseq #284

Open
wants to merge 128 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 106 commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
a559ef4
Translate some functions and structs from Pulseq MATLAB to Julia
beorostica Jan 10, 2024
7626005
Add test code for writing a pulseq file from a Sequence struct
beorostica Jan 10, 2024
071ce8d
Merge branch 'master' into pulseq
beorostica Jan 15, 2024
20914f9
Organize code and tests for writing Pulseq functionality
beorostica Jan 15, 2024
5239213
Remove Pulseq written test files
beorostica Jan 16, 2024
d9aef17
Merge branch 'master' into pulseq
beorostica Jan 16, 2024
3b9d4d1
Merge branch 'master' into pulseq
beorostica Jan 19, 2024
cae64de
Load pulseq sequences faster and allow comparison
gabuzi Dec 3, 2023
efadc1a
Add a test for fast read sequence
beorostica Jan 23, 2024
b086efd
Restore previous tests in KomaMRIFiles
beorostica Jan 23, 2024
db4e10a
Merge read .seq optimization branch into pulseq
beorostica Jan 23, 2024
4be6f65
Merge branch 'master' into pulseq
beorostica Jan 23, 2024
e1ab97a
Test the optimized read function for reading more .seq examples
beorostica Jan 23, 2024
4dc29d9
Fix RF angles when writing .seq files
beorostica Jan 24, 2024
e5728b5
Remove some comments when testing the write pulseq functionality
beorostica Jan 24, 2024
fd8822f
Remove the optimized read pulseq fuctionality from the write pulseq …
beorostica Jan 25, 2024
cb07ea1
Fix the precision of RF comparisons and RF delay
beorostica Jan 26, 2024
004dca2
Merge branch 'master' into pulseq
beorostica Apr 11, 2024
0d4d5e0
Fix RF angle when writing .seq files
beorostica Apr 11, 2024
7d05c70
Update KomaMRIBase/src/datatypes/Sequence.jl
beorostica Apr 11, 2024
372b751
Update KomaMRIBase/src/datatypes/Sequence.jl
beorostica Apr 11, 2024
8749d36
Update KomaMRIBase/src/datatypes/Sequence.jl
beorostica Apr 11, 2024
70f584e
Update KomaMRIBase/src/datatypes/sequence/ADC.jl
beorostica Apr 11, 2024
807c0c4
Update KomaMRIBase/src/datatypes/sequence/RF.jl
beorostica Apr 11, 2024
0f1a395
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
da90d4c
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
a91698b
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
e39fcf2
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
2afd1fb
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
4449abe
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
93f7d86
Update KomaMRIFiles/test/runtests.jl
beorostica Apr 11, 2024
e811d18
Update KomaMRIBase/src/datatypes/Sequence.jl
beorostica Apr 11, 2024
98f87db
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
ee4305c
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
9e1b9b1
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
972e623
Update KomaMRIFiles/test/runtests.jl
beorostica Apr 11, 2024
62993c1
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
bc4b83c
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
6cbf779
Update KomaMRIFiles/test/runtests.jl
beorostica Apr 11, 2024
5eee63a
Update KomaMRIFiles/test/runtests.jl
beorostica Apr 11, 2024
2a31539
Update KomaMRIFiles/test/runtests.jl
beorostica Apr 11, 2024
082668b
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
874677e
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
5a06916
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
eff7f20
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
4600a27
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
64e9800
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
30d1c72
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
bfea890
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
579031e
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
6c3bd4c
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
24e6c90
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
dd723da
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
0f186bd
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
ac99a92
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
37c0af3
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
595df76
Add reviewdog suggestions
beorostica Apr 11, 2024
23c1dc6
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
a54fe2f
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
54c92eb
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
b3c1658
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
5cae2ed
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
2b0a634
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
6daf695
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
48e4aaf
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
3b3d5c7
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 11, 2024
7d25a25
Delete `in` word in write pulseq file
beorostica Apr 11, 2024
a5466e5
Delete blank spaces from write pulseq file
beorostica Apr 11, 2024
04519f0
Apply format style to write pulseq file
beorostica Apr 11, 2024
d729110
Add some reviewdog suggestions
beorostica Apr 11, 2024
c16fd19
Add some reviewdog suggestions
beorostica Apr 11, 2024
32f3295
Add some reviewdog suggestions
beorostica Apr 11, 2024
58a7789
Create common pulseq examples folder for KomaMRIFiles tests
beorostica Apr 11, 2024
2456434
Add write sequence to API documentation
beorostica Apr 11, 2024
bbed561
Fix when writting zero amplitude gradients
beorostica Apr 12, 2024
8147b7b
Remove magsign function when writing pulseq
beorostica Apr 12, 2024
f00f10d
Add reviewdog style suggestion
beorostica Apr 12, 2024
4c7729a
Remove duplicated compress function
beorostica Apr 12, 2024
b5dcbed
Add some spaces to comments
beorostica Apr 12, 2024
177d05d
Replace some reshapes to [x;;] notation
beorostica Apr 12, 2024
99f9328
Add reviewdog style for __VERSION__
beorostica Apr 12, 2024
2f193cd
Update KomaMRIPlots/src/KomaMRIPlots.jl
beorostica Apr 12, 2024
80f055c
Compare angles with exponential expression
beorostica Apr 12, 2024
e9c20d6
Add functions for safe comparison when writing pulseq
beorostica Apr 15, 2024
43dcc62
Refactor safe comparison functions when writing pulseq
beorostica Apr 15, 2024
08cd263
Consider all definitions when writing pulseq
beorostica Apr 15, 2024
bbb0858
Update runtests for KomaMRIFiles
beorostica Apr 15, 2024
0b668ec
Define event on when writing pulseq
beorostica Apr 16, 2024
2dd30b0
Refactor get unique events when writing pulseq
beorostica Apr 16, 2024
bcf5515
Refactor and rewrite some RF related variables and functions when wri…
beorostica Apr 16, 2024
d26108b
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 16, 2024
c6a2140
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 16, 2024
511dc91
Rename some ADC related variables when writing pulseq
beorostica Apr 16, 2024
72718e6
Rename some Grad related variables when writing pulseq
beorostica Apr 16, 2024
793d2ea
Improve readability of @printf when writing pulseq
beorostica Apr 16, 2024
517d7e2
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 16, 2024
5c2da8c
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 16, 2024
b835beb
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 16, 2024
458609e
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 16, 2024
d90bd4c
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 16, 2024
69841da
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 16, 2024
64ca46b
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 16, 2024
bbd5715
Update KomaMRIFiles/src/Sequence/WritePulseq.jl
beorostica Apr 16, 2024
aba0007
Fix @printf bugs when writing pulseq
beorostica Apr 16, 2024
600770b
Refactor runtests for KomaMRIFiles
beorostica Apr 16, 2024
9832de0
Remove extensions section when writing pulseq
beorostica Apr 16, 2024
7fd0f4b
Refactor runtests for KomaMRIFiles
beorostica Apr 16, 2024
35baedd
Update KomaMRIFiles/test/runtests.jl
beorostica Apr 16, 2024
fdd77f8
Update KomaMRIFiles/test/runtests.jl
beorostica Apr 16, 2024
bc5d51f
Rename some Shapes related variables when writing pulseq
beorostica Apr 17, 2024
b7e6e3c
Add table helper functions when writing pulseq
beorostica Apr 17, 2024
cc359cc
Add pacth for considering gradients with zero amplitude when writing …
beorostica Apr 17, 2024
7d6b94e
Refactor some new lines when writing pulseq
beorostica Apr 17, 2024
3d33e3c
Compare angles with isapprox when writing pulseq
beorostica Apr 17, 2024
88e6482
Create intermediate pulseq object when writing pulseq
beorostica Apr 18, 2024
f330473
Add reviewdog suggestions
beorostica Apr 18, 2024
724b10f
Refactor with tuples when writing pulseq
beorostica Apr 18, 2024
6d1a75b
Add get pulseq object function when writing pulseq
beorostica Apr 18, 2024
12c1927
Merge master into pulseq writer branch
beorostica Apr 23, 2024
5c8a96e
Fix bug when writing pulseq
beorostica Apr 23, 2024
ddd53f9
Optimize functions for writing pulseq
beorostica Apr 24, 2024
3f7be9f
Set zero-Grad when reading pulseq gradients with zero amplitude
beorostica Apr 24, 2024
c73dd9a
Optimize function when writing pulseq
beorostica Apr 24, 2024
80aa28b
Revert return conditional when reading pulseq gradients
beorostica Apr 24, 2024
636d359
Add a return statement
beorostica Apr 24, 2024
41588bf
Remove some aux functions when writing pulseq
beorostica Apr 25, 2024
17fbe9b
Merge branch 'master' into pulseq
cncastillo May 30, 2024
1d2df48
Merge branch 'master' into pulseq
cncastillo Jun 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ src/ui/assets/*
examples/3.koma_paper/comparison_accuracy/**/*.mrd
examples/3.koma_paper/mrf/**/*.mrd
examples/3.koma_paper/comparison_accuracy/**/*.mat
examples/3.koma_paper/comparison_accuracy/**/*.h5
examples/3.koma_paper/comparison_accuracy/**/*.h5
*.wseq
6 changes: 4 additions & 2 deletions KomaMRIBase/src/KomaMRIBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ export get_Mk, get_kspace, get_M0, get_M1, get_M2
include("sequences/PulseDesigner.jl")
export PulseDesigner

#Package version, KomaMRIBase.__VERSION__
# Package version, KomaMRIBase.__VERSION__
using Pkg
__VERSION__ = VersionNumber(Pkg.TOML.parsefile(joinpath(@__DIR__, "..", "Project.toml"))["version"])
__VERSION__ = VersionNumber(
Pkg.TOML.parsefile(joinpath(@__DIR__, "..", "Project.toml"))["version"]
)

end # module KomaMRIBase
37 changes: 25 additions & 12 deletions KomaMRIBase/src/datatypes/Sequence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,35 @@
-(x::Sequence) = Sequence(-x.GR, x.RF, x.ADC, x.DUR, x.DEF)
*(x::Sequence, α::Real) = Sequence(α .* x.GR, x.RF, x.ADC, x.DUR, x.DEF)
*(α::Real, x::Sequence) = Sequence(α .* x.GR, x.RF, x.ADC, x.DUR, x.DEF)
*(x::Sequence, α::ComplexF64) = Sequence(x.GR, α.*x.RF, x.ADC, x.DUR, x.DEF)
*(α::ComplexF64, x::Sequence) = Sequence(x.GR, α.*x.RF, x.ADC, x.DUR, x.DEF)
*(x::Sequence, A::Matrix{Float64}) = Sequence(A*x.GR, x.RF, x.ADC, x.DUR, x.DEF) #TODO: change this, Rotation fo waveforms is broken
*(A::Matrix{Float64}, x::Sequence) = Sequence(A*x.GR, x.RF, x.ADC, x.DUR, x.DEF) #TODO: change this, Rotation fo waveforms is broken
/(x::Sequence, α::Real) = Sequence(x.GR/α, x.RF, x.ADC, x.DUR, x.DEF)
*(x::Sequence, α::ComplexF64) = Sequence(x.GR, α .* x.RF, x.ADC, x.DUR, x.DEF)
*(α::ComplexF64, x::Sequence) = Sequence(x.GR, α .* x.RF, x.ADC, x.DUR, x.DEF)
*(x::Sequence, A::Matrix{Float64}) = Sequence(A * x.GR, x.RF, x.ADC, x.DUR, x.DEF) #TODO: change this, Rotation fo waveforms is broken

Check warning on line 126 in KomaMRIBase/src/datatypes/Sequence.jl

View check run for this annotation

Codecov / codecov/patch

KomaMRIBase/src/datatypes/Sequence.jl#L126

Added line #L126 was not covered by tests
*(A::Matrix{Float64}, x::Sequence) = Sequence(A * x.GR, x.RF, x.ADC, x.DUR, x.DEF) #TODO: change this, Rotation fo waveforms is broken
/(x::Sequence, α::Real) = Sequence(x.GR / α, x.RF, x.ADC, x.DUR, x.DEF)
#Grad operations
+(s::Sequence, g::Grad) = s + Sequence(reshape([g],1,1)) #Changed [a;;] for reshape(a,1,1) for Julia 1.6
+(g::Grad, s::Sequence) = Sequence(reshape([g],1,1)) + s #Changed [a;;] for reshape(a,1,1) for Julia 1.6
+(s::Sequence, g::Grad) = s + Sequence([g;;])
+(g::Grad, s::Sequence) = Sequence([g;;]) + s
#RF operations
+(s::Sequence, r::RF) = s + Sequence(reshape([Grad(0.0,0.0)],1,1),reshape([r],1,1)) #Changed [a;;] for reshape(a,1,1) for Julia 1.6
+(r::RF, s::Sequence) = Sequence(reshape([Grad(0.0,0.0)],1,1),reshape([r],1,1)) + s #Changed [a;;] for reshape(a,1,1) for Julia 1.6
+(s::Sequence, r::RF) = s + Sequence([Grad(0.0, 0.0);;], [r;;])
+(r::RF, s::Sequence) = Sequence([Grad(0.0, 0.0);;], [r;;]) + s
#ADC operations
+(s::Sequence, a::ADC) = s + Sequence(reshape([Grad(0.0,0.0)],1,1),reshape([RF(0.0,0.0)],1,1),[a]) #Changed [a;;] for reshape(a,1,1) for Julia 1.6
+(a::ADC, s::Sequence) = Sequence(reshape([Grad(0.0,0.0)],1,1),reshape([RF(0.0,0.0)],1,1),[a]) + s #Changed [a;;] for reshape(a,1,1) for Julia 1.6
+(s::Sequence, a::ADC) = s + Sequence([Grad(0.0, 0.0);;], [RF(0.0, 0.0);;], [a])
+(a::ADC, s::Sequence) = Sequence([Grad(0.0, 0.0);;], [RF(0.0, 0.0);;], [a]) + s
#Sequence object functions
size(x::Sequence) = size(x.GR[1,:])
size(x::Sequence) = size(x.GR[1, :])

"""
For comparing two `Sequence`s custom types
"""
Base.isapprox(s1::Sequence, s2::Sequence) = begin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The syntax Base.isapprox instead of import Base: isapprox is not consistent with the rest of the code. Julia Blue (#187) recommends Base.isapprox, we need to choose one or the other.

beorostica marked this conversation as resolved.
Show resolved Hide resolved
(length(s1) != length(s2)) && return false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this syntax Julia blue?

return all([

Check warning on line 146 in KomaMRIBase/src/datatypes/Sequence.jl

View check run for this annotation

Codecov / codecov/patch

KomaMRIBase/src/datatypes/Sequence.jl#L144-L146

Added lines #L144 - L146 were not covered by tests
s1.ADC[i] ≈ s2.ADC[i] &&
s1.RF[i] ≈ s2.RF[i] &&
s1.GR[i] ≈ s2.GR[i] &&
s1.DUR[i] ≈ s2.DUR[i] for i in 1:length(s1)
])
end

"""
y = is_ADC_on(x::Sequence)
Expand Down
11 changes: 7 additions & 4 deletions KomaMRIBase/src/datatypes/sequence/ADC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ mutable struct ADC
end
end

# ADC comparison
Base.isapprox(adc1::ADC, adc2::ADC) = begin
return all(length(getfield(adc1, k)) ≈ length(getfield(adc2, k)) for k ∈ fieldnames(ADC))
all(getfield(adc1, k) ≈ getfield(adc2, k) for k ∈ fieldnames(ADC))
"""
For comparing two `ADC`s custom types
beorostica marked this conversation as resolved.
Show resolved Hide resolved
"""
function Base.isapprox(adc1::ADC, adc2::ADC)
return all(
length(getfield(adc1, k)) ≈ length(getfield(adc2, k)) for k in fieldnames(ADC)
) && all(getfield(adc1, k) ≈ getfield(adc2, k) for k in fieldnames(ADC))
end

"""
Expand Down
35 changes: 19 additions & 16 deletions KomaMRIBase/src/datatypes/sequence/Grad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,25 +167,28 @@
- `y`: (`::Vector{Any}` or `::Matrix{Any}`) vector or matrix with the property defined
by the symbol `f` for all elements of the Grad vector or matrix `x`
"""
getproperty(x::Vector{Grad}, f::Symbol) = getproperty.(x,f)
getproperty(x::Vector{Grad}, f::Symbol) = getproperty.(x, f)

Check warning on line 170 in KomaMRIBase/src/datatypes/sequence/Grad.jl

View check run for this annotation

Codecov / codecov/patch

KomaMRIBase/src/datatypes/sequence/Grad.jl#L170

Added line #L170 was not covered by tests
getproperty(x::Matrix{Grad}, f::Symbol) = begin
if f == :x
x[1,:]
elseif f == :y && size(x,1) >= 2
x[2,:]
elseif f == :z && size(x,1) >= 3
x[3,:]
elseif f == :dur
maximum(dur.(x), dims=1)[:]
else
getproperty.(x,f)
end
if f == :x
x[1, :]
elseif f == :y && size(x, 1) >= 2
x[2, :]
elseif f == :z && size(x, 1) >= 3
x[3, :]
elseif f == :dur
maximum(dur.(x); dims=1)[:]
else
getproperty.(x, f)
end
end

# Gradient comparison
Base.isapprox(gr1::Grad, gr2::Grad) = begin
return all(length(getfield(gr1, k)) ≈ length(getfield(gr2, k)) for k ∈ fieldnames(Grad)) &&
all(getfield(gr1, k) ≈ getfield(gr2, k) for k ∈ fieldnames(Grad))
"""
For comparing two `Grad`s custom types
"""
function Base.isapprox(gr1::Grad, gr2::Grad)
return all(
length(getfield(gr1, k)) ≈ length(getfield(gr2, k)) for k in fieldnames(Grad)
) && all(all(getfield(gr1, k) .≈ getfield(gr2, k)) for k in fieldnames(Grad))
end

# Gradient operations
Expand Down
44 changes: 25 additions & 19 deletions KomaMRIBase/src/datatypes/sequence/RF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,35 @@
- `y`: (`::Vector{Any}` or `::Matrix{Any}`) vector with the property defined by the
symbol `f` for all elements of the RF vector or matrix `x`
"""
getproperty(x::Vector{RF}, f::Symbol) = getproperty.(x,f)
getproperty(x::Vector{RF}, f::Symbol) = getproperty.(x, f)

Check warning on line 81 in KomaMRIBase/src/datatypes/sequence/RF.jl

View check run for this annotation

Codecov / codecov/patch

KomaMRIBase/src/datatypes/sequence/RF.jl#L81

Added line #L81 was not covered by tests
cncastillo marked this conversation as resolved.
Show resolved Hide resolved
getproperty(x::Matrix{RF}, f::Symbol) = begin
if f == :Bx
real.(getproperty.(x,:A))
elseif f == :By
imag.(getproperty.(x,:A))
elseif f == :Δf
getproperty.(x,:Δf)
elseif f == :T || f == :delay
getproperty.(x[1,:],f)
elseif f == :dur
T, delay = x.T, x.delay
ΔT = [sum(t) for t=T] .+ delay
ΔT
else
getproperty.(x,f)
end
if f == :Bx
real.(getproperty.(x, :A))

Check warning on line 84 in KomaMRIBase/src/datatypes/sequence/RF.jl

View check run for this annotation

Codecov / codecov/patch

KomaMRIBase/src/datatypes/sequence/RF.jl#L84

Added line #L84 was not covered by tests
elseif f == :By
imag.(getproperty.(x, :A))

Check warning on line 86 in KomaMRIBase/src/datatypes/sequence/RF.jl

View check run for this annotation

Codecov / codecov/patch

KomaMRIBase/src/datatypes/sequence/RF.jl#L86

Added line #L86 was not covered by tests
elseif f == :Δf
getproperty.(x, :Δf)

Check warning on line 88 in KomaMRIBase/src/datatypes/sequence/RF.jl

View check run for this annotation

Codecov / codecov/patch

KomaMRIBase/src/datatypes/sequence/RF.jl#L88

Added line #L88 was not covered by tests
elseif f == :T || f == :delay
getproperty.(x[1, :], f)
elseif f == :dur
T, delay = x.T, x.delay
ΔT = [sum(t) for t in T] .+ delay
ΔT
beorostica marked this conversation as resolved.
Show resolved Hide resolved
else
getproperty.(x, f)
end
end

# RF comparison
"""
For comparing two `RF`s custom types
"""
Base.isapprox(rf1::RF, rf2::RF) = begin
return all(length(getfield(rf1, k)) == length(getfield(rf2, k)) for k ∈ fieldnames(RF))
all(≈(getfield(rf1, k), getfield(rf2, k), atol=1e-9) for k ∈ fieldnames(RF))
return all(length(getfield(rf1, k)) == length(getfield(rf2, k)) for k in fieldnames(RF)) &&
all(size(getfield(rf1, k)) == size(getfield(rf2, k)) for k in fieldnames(RF)) &&
all(
all(isapprox.(getfield(rf1, k), getfield(rf2, k), atol=1e-9)) for
k in fieldnames(RF)
)
end

# Properties
Expand Down
6 changes: 4 additions & 2 deletions KomaMRICore/src/KomaMRICore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ export signal_to_raw_data
export Mag
export simulate, simulate_slice_profile

#Package version, KomaMRICore.__VERSION__
# Package version, KomaMRICore.__VERSION__
using Pkg
__VERSION__ = VersionNumber(Pkg.TOML.parsefile(joinpath(@__DIR__, "..", "Project.toml"))["version"])
__VERSION__ = VersionNumber(
Pkg.TOML.parsefile(joinpath(@__DIR__, "..", "Project.toml"))["version"]
)

end
3 changes: 3 additions & 0 deletions KomaMRIFiles/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
KomaMRIBase = "d0bc0b20-b151-4d03-b2a4-6ca51751cb9c"
MAT = "23992714-dd62-5051-b70f-ba57cb901cac"
MD5 = "6ac74813-4b46-53a4-afec-0b5dc9d7885c"
MRIFiles = "5a6f062f-bf45-497d-b654-ad17aae2a530"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Scanf = "6ef1bc8b-493b-44e1-8d40-549aa65c4b41"

Expand All @@ -18,6 +20,7 @@ FileIO = "1"
HDF5 = "0.16, 0.17"
KomaMRIBase = "0.8"
MAT = "0.10"
MD5 = "0.2"
MRIFiles = "0.1, 0.2, 0.3"
Pkg = "1.4"
Reexport = "1"
Expand Down
12 changes: 8 additions & 4 deletions KomaMRIFiles/src/KomaMRIFiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@ module KomaMRIFiles

using KomaMRIBase
using Scanf, FileIO, HDF5, MAT # IO related
using Printf, MD5 # For writing .seq files from Sequence struct

using Reexport
using MRIFiles
import MRIFiles: insertNode
@reexport using MRIFiles: ISMRMRDFile
@reexport using FileIO: save

include("Sequence/Pulseq.jl")
include("Sequence/ReadPulseq.jl")
include("Sequence/WritePulseq.jl")
include("Phantom/JEMRIS.jl")
include("Phantom/MRiLab.jl")

export read_seq # Pulseq
export read_phantom_jemris, read_phantom_MRiLab # Phantom
export read_seq, write_seq # Pulseq
export read_phantom_jemris, read_phantom_MRiLab # Phantom

# Package version: KomaMRIFiles.__VERSION__
using Pkg
__VERSION__ = VersionNumber(Pkg.TOML.parsefile(joinpath(@__DIR__, "..", "Project.toml"))["version"])
__VERSION__ = VersionNumber(
Pkg.TOML.parsefile(joinpath(@__DIR__, "..", "Project.toml"))["version"]
)

end # module KomaMRIFiles
Loading
Loading