@@ -8,20 +8,22 @@ read_version Read the [VERSION] section of a sequence file.
88 identifier of an open MR sequence file and return it
99"""
1010function read_version (io)
11- major = @scanf (readline (io), " major %i" , Int)[end ]
12- minor = @scanf (readline (io), " minor %i" , Int)[end ]
13- revision = @scanf (readline (io), " revision %i" , Int)[end ]
14-
15- version_combined = 1_000_000 * major+ 1_000 * minor+ revision
16-
17- @assert major == 1 " Unsupported version_major $major "
18- if version_combined < 1002000
19- @error " Unsupported version $major .$minor .$revision , only file format revision 1.2.0 and above are supported"
20- elseif version_combined < 1003001
21- @warn " Loading older Pulseq format file (version $major .$minor .$revision ) some code may not function as expected"
11+ pulseq_version = VersionNumber (
12+ @scanf (readline (io), " major %i" , Int)[end ],
13+ @scanf (readline (io), " minor %i" , Int)[end ],
14+ @scanf (readline (io), " revision %i" , Int)[end ],
15+ )
16+
17+ @assert pulseq_version. major == 1 " Unsupported version_major $(pulseq_version. major) "
18+ if pulseq_version < v " 1.2.0"
19+ @error " Unsupported Pulseq $(pulseq_version) , only file format revision 1.2.0 and above are supported"
20+ elseif pulseq_version < v " 1.3.1"
21+ @warn " Loading older Pulseq $(pulseq_version) ; some code may not function as expected"
22+ elseif pulseq_version >= v " 1.5.0"
23+ @warn " Pulseq $(pulseq_version) not yet supported by this KomaMRIFiles release. Track progress at https://github.com/JuliaHealth/KomaMRI.jl/pull/614"
2224 end
2325
24- major, minor, revision, version_combined
26+ pulseq_version
2527end
2628
2729"""
@@ -76,12 +78,12 @@ read_blocks Read the [BLOCKS] section of a sequence file.
7678 library=read_blocks(fid) Read blocks from file identifier of an
7779 open MR sequence file and return the event table.
7880"""
79- function read_blocks (io, blockDurationRaster, version_combined )
81+ function read_blocks (io, blockDurationRaster, pulseq_version )
8082 eventTable = Dict {Int64, Vector{Int64}} ()
8183 blockDurations = Dict {Int64, Float64} ()
8284 delayIDs_tmp = Dict {Int64, Float64} ()
8385 while true
84- if version_combined <= 1002001
86+ if pulseq_version <= v " 1.2.1 "
8587 NumberBlockEvents = 7
8688 else
8789 NumberBlockEvents = 8
@@ -92,13 +94,13 @@ function read_blocks(io, blockDurationRaster, version_combined)
9294 blockEvents = parse .(Int64, split (read_event))
9395
9496 if blockEvents[1 ] != 0
95- if version_combined <= 1002001
97+ if pulseq_version <= v " 1.2.1 "
9698 eventTable[blockEvents[1 ]] = Int64[0 ; blockEvents[3 : end ]. .. ; 0 ]
9799 else
98100 eventTable[blockEvents[1 ]] = Int64[0 ; blockEvents[3 : end ]. .. ]
99101 end
100102
101- if version_combined >= 1004000
103+ if pulseq_version >= v " 1.4.0 "
102104 blockDurations[blockEvents[1 ]] = blockEvents[2 ]* blockDurationRaster
103105 else
104106 delayIDs_tmp[blockEvents[1 ]] = blockEvents[2 ]
@@ -375,9 +377,7 @@ julia> plot_seq(seq)
375377"""
376378function read_seq (filename)
377379 @info " Loading sequence $(basename (filename)) ..."
378- version_combined = 0
379- version_major = 0
380- version_minor = 0
380+ pulseq_version = v " 0.0.0"
381381 gradLibrary = Dict ()
382382 def = Dict ()
383383 signature = " "
@@ -403,21 +403,21 @@ function read_seq(filename)
403403 elseif section == " [DEFINITIONS]"
404404 def = read_definitions (io)
405405 elseif section == " [VERSION]"
406- version_major, version_minor, _, version_combined = read_version (io)
406+ pulseq_version = read_version (io)
407407 elseif section == " [BLOCKS]"
408- if version_combined == 0
408+ if pulseq_version == v " 0.0.0 "
409409 @error " Pulseq file MUST include [VERSION] section prior to [BLOCKS] section"
410410 end
411- blockEvents, blockDurations, delayInd_tmp = read_blocks (io, def[" BlockDurationRaster" ], version_combined )
411+ blockEvents, blockDurations, delayInd_tmp = read_blocks (io, def[" BlockDurationRaster" ], pulseq_version )
412412 elseif section == " [RF]"
413- if version_combined >= 1004000
413+ if pulseq_version >= v " 1.4.0 "
414414 rfLibrary = read_events (io, [1 / γ 1 1 1 1e-6 1 1 ]) # this is 1.4.x format
415415 else
416416 rfLibrary = read_events (io, [1 / γ 1 1 1e-6 1 1 ]) # this is 1.3.x and below
417417 # we will have to scan through the library later after all the shapes have been loaded
418418 end
419419 elseif section == " [GRADIENTS]"
420- if version_combined >= 1004000
420+ if pulseq_version >= v " 1.4.0 "
421421 gradLibrary = read_events (io, [1 / γ 1 1 1e-6 ]; type= ' g' , eventLibrary= gradLibrary) # this is 1.4.x format
422422 else
423423 gradLibrary = read_events (io, [1 / γ 1 1e-6 ]; type= ' g' , eventLibrary= gradLibrary) # this is 1.3.x and below
@@ -427,12 +427,12 @@ function read_seq(filename)
427427 elseif section == " [ADC]"
428428 adcLibrary = read_events (io, [1 1e-9 1e-6 1 1 ])
429429 elseif section == " [DELAYS]"
430- if version_combined >= 1004000
430+ if pulseq_version >= v " 1.4.0 "
431431 @error " Pulseq file revision 1.4.0 and above MUST NOT contain [DELAYS] section"
432432 end
433433 tmp_delayLibrary = read_events (io, 1e-6 );
434434 elseif section == " [SHAPES]"
435- shapeLibrary = read_shapes (io, (version_major == 1 && version_minor < 4 ))
435+ shapeLibrary = read_shapes (io, (pulseq_version . major == 1 && pulseq_version . minor < 4 ))
436436 elseif section == " [EXTENSIONS]"
437437 extensionLibrary = read_extension_blocks (io)
438438 elseif section == " [SIGNATURE]"
@@ -465,7 +465,7 @@ function read_seq(filename)
465465 end
466466 end
467467 # fix blocks, gradients and RF objects imported from older versions
468- if version_combined < 1004000
468+ if pulseq_version < v " 1.4.0 "
469469 # scan through the RF objects
470470 for i = 0 : length (rfLibrary)- 1
471471 rfLibrary[i][" data" ] = [rfLibrary[i][" data" ][1 : 3 ]' 0.0 rfLibrary[i][" data" ][4 : end ]' ]
@@ -531,7 +531,7 @@ function read_seq(filename)
531531 seq. DEF = merge (obj[" definitions" ], seq. DEF)
532532 # Koma specific details for reconstrucion
533533 seq. DEF[" FileName" ] = basename (filename)
534- seq. DEF[" PulseqVersion" ] = version_combined
534+ seq. DEF[" PulseqVersion" ] = pulseq_version
535535 seq. DEF[" signature" ] = signature
536536 # Guessing recon dimensions
537537 seq. DEF[" Nx" ] = get (seq. DEF, " Nx" , maximum (adc. N for adc = seq. ADC))
0 commit comments