Skip to content

Mag p#97

Merged
J-Endres merged 6 commits intomainfrom
mag_p
Dec 10, 2024
Merged

Mag p#97
J-Endres merged 6 commits intomainfrom
mag_p

Conversation

@SWeinmueller
Copy link
Collaborator

Return the correct mag _P

@J-Endres
Copy link
Collaborator

J-Endres commented Dec 9, 2024

Do we have consensus that we rather want the magnetization including encoding etc. than without? Or should we provide an additional flag to select this?

@SWeinmueller
Copy link
Collaborator Author

I see no application where we need the signal without relaxation, but we could use another flag to be more general and we don't have to decide now.

@mzaiss
Copy link
Collaborator

mzaiss commented Dec 10, 2024 via email

@J-Endres
Copy link
Collaborator

We could have the option to return either + states or ADC mag, as made here: #101

If that's okay, merge into mag_p before merging mag_p into main

suggestion to make two separate options for returning + states and measured magnetization
@J-Endres
Copy link
Collaborator

Suggested change: remove return_mag_z and return_mag_p in favor of a clear_mag_state flag that defaults to false - this allows to extract all the data from the graph object, including magnetization.
return_mag_adc stays.

Example usage:

graph = mr0.compute_graph(seq, data)
signal, mag_adc = mr0.execute_graph(graph, seq, data, return_mag_adc=True, clear_state_mag=False)

# Extract all states of the desired type and if it was simulated (mag is not None)
mag_p = [[state.mag for state in rep if state.dist_type == "+" and state.mag is not None] for rep in graph]
mag_z = [[state.mag for state in rep if state.dist_type in ["z", "z0"] and state.mag is not None] for rep in graph]

@SWeinmueller
Copy link
Collaborator Author

It works as desired. Nevertheless, you have to think carefully about which states you take into account, as some of these are also dephased.

changed sim to not return mag_p and mag_z but instead leave it in the graph
@SWeinmueller
Copy link
Collaborator Author

mag_adc:

img = torch.zeros([*sz], dtype=torch.complex64)
mag = torch.stack([m[0] for m in mag_adc])
rows = 8
cols = 8
factor = int(sz[0] / rows)

# Generate plots for each subplot
plt.figure(dpi=300)
plt.suptitle("Transversal adc Mag", fontsize=16)
for i in range(rows):
    for j in range(cols):
        plt.subplot(rows, cols, i * cols + j + 1)
        img[obj_p.recover().PD>0] = mag[i*factor,j*factor,:]
        util.plot3D(img.abs())
        plt.clim(0,0.15)
        plt.axis('off')
# Show the plot
plt.show()

# Generate plots for each subplot
plt.figure(dpi=300)
plt.suptitle("Transversal adc Mag", fontsize=16)
for i in range(rows):
    for j in range(cols):
        plt.subplot(rows, cols, i * cols + j + 1)
        img[obj_p.recover().PD>0] = mag[i*factor,j*factor,:]
        util.plot3D(img.angle())
        plt.clim(0,0.15)
        plt.axis('off')
# Show the plot
plt.show()

grafik
grafik

@J-Endres J-Endres merged commit 0810bb8 into main Dec 10, 2024
11 of 12 checks passed
@J-Endres J-Endres deleted the mag_p branch December 10, 2024 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants