code { white-space: pre; /* or pre-wrap */ }
This is what you can do when you want to extract the static B1 solution from a DICOM.
Published on

Sometimes you need to recover a specific B1 solution from a scan. For example
you deleted accidentally your B1 shim cash
you are doing a quality check retrospectively
you want to use the exact B1 shim solution for the same head in another session.
This can happen. But good news is you can phoenix it from the dicom. In the same way you could extract it from the .dat files too.
Open the dicom file with a text editor, like VS code. Just open it as text file. Search for the line
sTXSPEC.aTxScaleFactor
Those are the B1 scale factors as Real/Imag numbers.
To use them at the scanner with the AdjValidate tool or Eddie's B1 Shim tool you need to convert them into Mag/Phase.
Here's how you can do this quickly: Create new text file i.e. "from_dicom.txt". Copy all the lines into this file

Now simply copy the following script in your terminal. Don't forget to edit the re-name you gave the text file with the scale factors if you used a different name than "from_dicom.txt".
#--------------------------------------------------------#
echo "Task : Calcualting B1 solution from DICOM data"
awk '
BEGIN {
printf("AdjValidate -txscale -set ");
}
{
val = $NF;
if ($0 ~ /\.dRe/) {
re = val;
} else if ($0 ~ /\.dIm/) {
im = val;
mag = sqrt(re*re + im*im);
phase_rad = atan2(im, re);
phase_deg = phase_rad * (180 / 3.14159265358979323846);
printf("%.4f %.4f ", mag, phase_deg);
}
}
END {
printf("\n");
}' from_dcm.txt > Excitation_B1_solution.txt
echo "B1 solution created! Name: Excitation_B1_solution.txt"
#--------------------------------------------------------#
The output is a text file called "Excitation_B1_solution.txt" that contains a final B1 solution. You can directly load this .txt file with Eddie's B1 shim cache tool, or copy it into the command shell at the scanner (with a sequence selected for editing).

