Skip to content

Commit

Permalink
forget api and remove channel dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
aTrotier committed Nov 12, 2024
1 parent 42a9cff commit b255cf7
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 32 deletions.
8 changes: 4 additions & 4 deletions docs/lit/examples/advanced_reco.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ d_under = reconstruction_MP2RAGE(path_bruker; mean_NR=true)
begin
f = Figure(size=(500,400))
ax=Axis(f[1,1],title="TI₁ undersampled")
h=heatmap!(ax,abs.(d_under["im_reco"][:,:,60,1,1,1]),colormap=:grays)
h=heatmap!(ax,abs.(d_under["im_reco"][:,:,60,1,1]),colormap=:grays)

ax=Axis(f[1,2],title="TI₁ CS")
h=heatmap!(ax,abs.(d["im_reco"][:,:,60,1,1,1]),colormap=:grays)
h=heatmap!(ax,abs.(d["im_reco"][:,:,60,1,1]),colormap=:grays)


ax=Axis(f[2,1],title="T₁ map undersampled")
h=heatmap!(ax,d_under["T1map"][:,:,60,1,1],colorrange = (500,2000))
h=heatmap!(ax,d_under["T1map"][:,:,60,1],colorrange = (500,2000))

ax=Axis(f[2,2],title="T₁ map CS")
h=heatmap!(ax,d["T1map"][:,:,60,1,1],colorrange = (500,2000))
h=heatmap!(ax,d["T1map"][:,:,60,1],colorrange = (500,2000))

for ax in f.content # hide decoration befor adding colorbar
hidedecorations!(ax)
Expand Down
18 changes: 9 additions & 9 deletions docs/lit/examples/simple_reco.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,32 @@ d = reconstruction_MP2RAGE(path_bruker; mean_NR=true)


# the result is a dictionnary with the following fields :
# - "im_reco" : (x,y,z,Number of Channel , Number of Repetition,TI) Complex
# - "MP2RAGE" : (x,y,z,Number of Channel , Number of Repetition) Float
# - "T1map" : (x,y,z,Number of Channel , Number of Repetition) Float
# - "im_reco" : (x,y,z, Number of Repetition,TI) Complex
# - "MP2RAGE" : (x,y,z , Number of Repetition) Float
# - "T1map" : (x,y,z , Number of Repetition) Float
# - "params_prot"
# - "params_reco"
# - "params_MP2RAGE"
#
# im_reco corresponds to the TI₁ and TI₂ images in the complex format with 6 dimensions :
# (x,y,z, Number of Channel , Number of Repetition,TI)
# im_reco corresponds to the TI₁ and TI₂ images in the complex format with 5 dimensions :
# (x,y,z , Number of Repetition,TI). Channels are combined during the reconstruction


# We can check the results

begin
f = Figure(size=(500,400))
ax=Axis(f[1,1],title="TI₁")
h=heatmap!(ax,abs.(d["im_reco"][:,:,60,1,1,1]),colormap=:grays)
h=heatmap!(ax,abs.(d["im_reco"][:,:,60,1,1]),colormap=:grays)

ax=Axis(f[1,2],title="TI₂")
h=heatmap!(ax,abs.(d["im_reco"][:,:,60,1,1,2]),colormap=:grays)
h=heatmap!(ax,abs.(d["im_reco"][:,:,60,1,2]),colormap=:grays)

ax=Axis(f[2,1],title="UNIT1 / MP2RAGE")
h=heatmap!(ax,d["MP2RAGE"][:,:,60,1,1],colormap=:grays)
h=heatmap!(ax,d["MP2RAGE"][:,:,60,1],colormap=:grays)

ax=Axis(f[2,2],title="T₁ map")
h=heatmap!(ax,d["T1map"][:,:,60,1,1],colorrange = (500,2000))
h=heatmap!(ax,d["T1map"][:,:,60,1],colorrange = (500,2000))

for ax in f.content # hide decoration befor adding colorbar
hidedecorations!(ax)
Expand Down
4 changes: 4 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

```@autodocs
Modules = [SEQ_BRUKER_a_MP2RAGE_CS_360]
```
8 changes: 2 additions & 6 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
CurrentModule = SEQ_BRUKER_a_MP2RAGE_CS_360
```

# SEQ\_BRUKER\_a\_MP2RAGE\_CS\_360
# SEQ\_BRUKER\_A\_MP2RAGE\_CS\_360

Documentation for [SEQ_BRUKER_a_MP2RAGE_CS_360](https://github.com/aTrotier/SEQ_BRUKER_a_MP2RAGE_CS_360.jl).
Documentation for [SEQ_BRUKER_a_MP2RAGE_CS_360](https://github.com/CRMSB/SEQ_BRUKER_a_MP2RAGE_CS_360.jl).

```@index
```

```@autodocs
Modules = [SEQ_BRUKER_a_MP2RAGE_CS_360]
```
18 changes: 9 additions & 9 deletions src/BIDS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ This function writes data from a dictionary (`d`) in BIDS (Brain Imaging Data St
**Arguments:**
* `d` (Dict): A dictionary containing the data to be written. Expected key-value pairs:
* `im_reco` (Array): 5D array containing the reconstructed images.
* `MP2RAGE` (Array): Combined MP2RAGE image data.
* `T1map` (Array): Calculated T1 map from MP2RAGE images.
* `im_reco` (Array): 5D array containing the reconstructed images (x,y,z,NR,TI)
* `MP2RAGE` (Array): Combined MP2RAGE image data. (x,y,z,NR)
* `T1map` (Array): Calculated T1 map from MP2RAGE images. (x,y,z,NR)
* `params_prot` (Dict): Protocol parameters extracted from the Bruker file.
* `params_MP2RAGE` (Struct): Dictionary containing MP2RAGE specific parameters.
Expand Down Expand Up @@ -52,12 +52,12 @@ function write_bids_MP2RAGE(d::Dict,subname::AbstractString,folder="")
"_UNIT1",
"_T1map"]

data_ = [ abs.(d["im_reco"][:,:,:,1,:,1]),
angle.(d["im_reco"][:,:,:,1,:,1]),
d["im_reco"][:,:,:,1,:,1],
abs.(d["im_reco"][:,:,:,1,:,2]),
angle.(d["im_reco"][:,:,:,1,:,2]),
d["im_reco"][:,:,:,1,:,2],
data_ = [ abs.(d["im_reco"][:,:,:,:,1]),
angle.(d["im_reco"][:,:,:,:,1]),
d["im_reco"][:,:,:,:,1],
abs.(d["im_reco"][:,:,:,:,2]),
angle.(d["im_reco"][:,:,:,:,2]),
d["im_reco"][:,:,:,:,2],
d["MP2RAGE"],
d["T1map"]]

Expand Down
9 changes: 5 additions & 4 deletions src/reconstruction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Reconstructs MP2RAGE MRI data from a specified Bruker file path, returning image
# Returns
A dictionary with the following key-value pairs:
- `"im_reco"`: Reconstructed MP2RAGE image array, permuted to match the expected order.
- `"im_reco"`: Reconstructed MP2RAGE image array, permuted to match the expected order (x,y,z,number of Channel, Number of repetition)
- `"MP2RAGE"`: Combined MP2RAGE image data.
- `"T1map"`: Calculated T1 map from MP2RAGE images.
- `"params_reco"`: Dictionary of parameters used for reconstruction.
Expand Down Expand Up @@ -59,12 +59,13 @@ function reconstruction_MP2RAGE(path_bruker;mean_NR::Bool = false,paramsCS=Dict(

x_approx = reconstruction(acq, params).data
if mean_NR
x_approx = mean(x_approx,dims=6)
x_approx = mean(x_approx,dims=6) # average accross repetition
end
x_approx = permutedims(x_approx,(1,2,3,5,6,4))
x_approx = permutedims(x_approx,(1,2,3,5,6,4)) # permute to put contrast in last dimension
x_approx = x_approx[:,:,:,1,:,:] # remove coil dimension

## process data to extract T1 maps
MP2 = mp2rage_comb(x_approx[:,:,:,:,:,:])
MP2 = mp2rage_comb(x_approx)

p = params_from_seq(b)

Expand Down

0 comments on commit b255cf7

Please sign in to comment.