SPring-8 BL20B2 Reconstruction How-to
Setup
Reconstruction is performed on Windows machines in the cmd command terminal. If using PowerShell, commands may differ, I.e. bbb.bat
has to be invoked with .\bbb.bat
Instead.
Installation of the software
Downloads
The software relies on CUDA, you can download that here: https://developer.nvidia.com/cuda-downloads
The software itself was custom-written and is available at:http://www-bl20.spring8.or.jp/xct/index-e.html
Adding the path to the reconstruction software executables to the terminal
The path to the folder with the executables needs to be added to the environment variables in Windows, so that they can be called via terminal directly.
On Windows 10:
In Start Menu: View Advanced System Settings > Tab: Advanced > Button: Environment Variables
In the upper part of the window, it will show the variables for a single user, in the lower part, the variables for all users.
Then do Select Path > Edit… > New
. Add the folder where you are keeping the .exe files from SPring-8 (I.e. “C:\Program Files\SPring-8\ct-rec\exe”) to the paths.
Extracting images from a.HIS file
!WARNING: The reconstruction pipeline differs if during acquisition, “Skip IO” was turned on or off!
“Skip IO” = on means that flat-field acquisition between consecutive scans was skipped, in order to shorten the scan time and increase time resolution.
“Skip IO” = off means that separate flat-field acquisitions were performed for each scan, as per standard procedure
For reconstructing individual scans, skip to the last section.
With “Skip IO” = On
Change to raw directory in scan:
cd G:\<scan location>\raw
Execute spl_c
to write a batch-script, designed to split the Hamamatsu-Format a.HIS file to multiple files. Executing spl_c
without arguments will display the required arguments. The arguments are:
spl_c <number of projections> <number of flat-fields/dark-fields = “DIRECT” in acquisition window> <number of scans in a.HIS file>
spl_c 1801 30 3 > bbb.bat
Execute bbb.bat:
bbb.bat
With “Skip IO” = Off
Change to raw directory in scan:
cd G:\<scan location>\raw
Execute spl
to write a batch-script, designed to split the Hamamatsu-Format a.HIS file to multiple files. Executing spl
without arguments will display the required arguments. The arguments are:
spl <N-Shots> <number of scans>
<N-Shots> is the number of all projections + all flat-fields + all dark-fields. In our scans, this is 1801 + 2*30 + 30 = 1891:
spl 1891 2 > bbb.bat
Execute bbb.bat:
bbb.bat
Reconstruction
Reconstruct single scan
Enter the raw-folder of the individual scan:
cd G:\<scan location>\raw\001\raw
Execute conv.bat
. This creates a0001.img to a1891.img, which are all projections, flat-fields and dark-fields. It further creates:
- dark.img = averaged flat-field
- q0001.img = averaged flat-field from scan start
- q1804.img = averaged flat-fields from scan end
conv
Reconstruct a single slice to determine center of rotation. The arguments are the slice number (indexed from zero) and the manual center of rotation. If no second argument is provided, center of rotation will be calculated automatically. A single .tiff file will be written into the scan directory. New reconstructions will overwrite old ones without warning.
ct_rec_g_c 750
This program will provide the center of rotation value as an output as the third variable on the second line. This will be required as argument for the full reconstruction. (The first variable is the file name, the second is the pixel size, which will be 1.0 since it’s not set up)
To reconstruct the whole volume, one has to go up one folder from raw.
cd ..
Make a new folder for where the reconstruction will be stored
mkdir rec
Use the hp_tg_g_c
command to reconstruct the whole volume. Arguments are:
hp_tg_g_c <source folder> <pixel size> <center of rotation> <rotation angle of the reconstructed volume> <destination folder>
hp_tg_g_c raw 7.99 1023.0 0 rec
PowerShell script to reconstruct multiple single scans
The following script can be run in Windows PowerShell to automatize reconstruction after splitting the datasets. spl
and spl_c
do not work in PowerShell, and would need their own implementation (probably not difficult. Look at bbb.bat
, it’s quite simple).
# Execute in scan/raw, not in scan/raw/001/raw
$NumberOfScans = 5
$SingleSliceRecoSlice = 750
$PixelSize = 7.99
$RotationAngleRecoVolume = 0
for ($i = 1; $i -le $NumberOfScans; $i++)
{
# Convert 1, 2, 3 etc. to 001, 002, 003 etc.
$FolderNumber = '{0:d3}' -f $i
cd $FolderNumber
cd raw
./conv
# Reconstruct a single slice (1st argument of ct_rec_g_c, slice 750 in this case, zero-indexed), and stores each line as an element in an array $SingleRecoTerminalOutput
$SingleRecoTerminalOutput = ct_rec_g_c $SingleSliceRecoSlice
# Calls the 2nd element of $SingleRecoTerminalOutput, splits the tab-separated values in the string to a new array and stores it in a variable
$SingleRecoTerminalOutputSecondLine = $SingleRecoTerminalOutput[1].Split()
$CenterOfRotation = $SingleRecoTerminalOutputSecondLine[2]
cd ..
mkdir rec
$PixelSize $CenterOfRotation $RotationAngleRecoVolume rec
hp_tg_g_c raw
cd ..
}