Skip to content
Snippets Groups Projects
Commit 81c11e77 authored by Stephen Smith's avatar Stephen Smith
Browse files

added --tglobal option and fixed offset for --tcustom option

parent a2c010a8
No related branches found
No related tags found
No related merge requests found
......@@ -41,7 +41,7 @@ Option<bool> odd(string("--odd"), false,
string("use interleaved acquisition"),
false, no_argument);
Option<bool> down(string("--down"), false,
string("reverse slice indexing"),
string("reverse slice indexing (default is: slices were acquired bottom-up)"),
false, no_argument);
Option<string> inputname(string("-i,--in"), string(""),
string("filename of input timeseries"),
......@@ -52,6 +52,9 @@ Option<string> outputname(string("-o,--out"), string(""),
Option<string> tcustom(string("--tcustom"), string(""),
string("filename of single-column custom interleave timing file"),
false, requires_argument);
Option<float> tglobal(string("--tglobal"), 0.5,
string("global shift (default is 0.5 = no shift)"),
false, requires_argument);
Option<string> ocustom(string("--ocustom"), string(""),
string("filename of single-column custom interleave order file (first slice is referred to as 1 not 0)"),
false, requires_argument);
......@@ -106,45 +109,47 @@ int do_slice_correction()
ColumnVector userkernel = sinckernel1D("hanning", 7, 1201);
// for(int i=1; i<=1201; i++) cout << i << " " << userkernel(i) << endl;
float recenter = (((float) no_slices)/2 - 0.5)/ no_slices;
float recenter = (((float) no_slices)/2 - 0.5)/ no_slices; // only valid for slice-count-based corrections
for (int slice=1; slice<=no_slices; slice++) {
if (tcustom.set()) {
offset = -timings(slice, 1);
if (tglobal.set()) {
offset = 0.5 - tglobal.value();
} else if (tcustom.set()) {
offset = 0.5 - timings(slice, 1);
} else if (ocustom.set()) {
int local_count=1;
while (local_count <= no_slices) {
if (timings(local_count, 1) == slice) {
offset = -(local_count -1)* (slice_spacing / repeat_time);
offset = recenter -(local_count -1)* (slice_spacing / repeat_time);
local_count = no_slices + 1;
} else
local_count++;
}
} else if (odd.value()) { // acquisition order: 1,3,5, ..., 2,4,6 ...
if ((slice % 2) == 0) // even
offset = -( ceil((float)no_slices / 2) + ((slice -1)/ 2)) * (slice_spacing / repeat_time);
offset = recenter - ( ceil((float)no_slices / 2) + ((slice -1)/ 2)) * (slice_spacing / repeat_time);
else
offset = -((slice -1) / 2) * (slice_spacing / repeat_time);
offset = recenter - ((slice -1) / 2) * (slice_spacing / repeat_time);
} else if (down.value()) {
offset = -(no_slices - slice)* (slice_spacing / repeat_time);
offset = recenter - (no_slices - slice) * (slice_spacing / repeat_time);
} else {
offset = -(slice -1)* (slice_spacing / repeat_time);
offset = recenter - (slice -1) * (slice_spacing / repeat_time);
}
for (int x_pos = 0; x_pos < timeseries. xsize(); x_pos++)
for (int y_pos = 0; y_pos < timeseries. ysize(); y_pos++){
ColumnVector voxeltimeseries = timeseries.voxelts(x_pos,y_pos,slice-1);
ColumnVector interpseries = voxeltimeseries;
for (int time_step=1; time_step <= no_volumes; time_step++){
// interpseries(time_step) = interpolate_1d(voxeltimeseries, time_step - offset - recenter);
interpseries(time_step) = kernelinterpolation_1d(voxeltimeseries, time_step - offset - recenter, userkernel, 7);
// interpseries(time_step) = interpolate_1d(voxeltimeseries, time_step - offset);
interpseries(time_step) = kernelinterpolation_1d(voxeltimeseries, time_step - offset, userkernel, 7);
}
timeseries.setvoxelts(interpseries,x_pos,y_pos,slice-1);
}
if (verbose.value())
cerr << "Slice " << slice << " offset " << offset + recenter << endl;
cerr << "Slice " << slice << " offset " << offset << endl;
}
if (direction.value() == 1) timeseries. swapdimensions(3,2,1); // reverse Flip z and x
......@@ -170,6 +175,7 @@ int main (int argc,char** argv)
options.add(direction);
options.add(odd);
options.add(tcustom);
options.add(tglobal);
options.add(ocustom);
options.parse_command_line(argc, argv);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment