Skip to content

Commit

Permalink
WIP... Works but there is sth wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
ofgulban committed Apr 4, 2024
1 parent fa9fd6c commit e132d4d
Showing 1 changed file with 92 additions and 57 deletions.
149 changes: 92 additions & 57 deletions src/LN3_LAYERS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ int main(int argc, char* argv[]) {
*(innerGM_step + ii) = 1;
*(innerGM_dist + ii) = 0.;
} else {
*(innerGM_step + ii) = 0.;
*(innerGM_dist + ii) = std::numeric_limits<float>::max();
*(innerGM_step + ii) = 0;
*(innerGM_dist + ii) = 0.;
}
}

Expand All @@ -429,6 +429,7 @@ int main(int argc, char* argv[]) {
int jj;
int counter = 666;
while (counter != 0) {
// for (int iter = 0; iter != 12; ++iter) { // DEBUG
cout << " Processing voxels: " << size_undetermined << " -> " << size_determined << endl;

// Loop over undetermined voxels only
Expand All @@ -447,53 +448,55 @@ int main(int argc, char* argv[]) {
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dX < d) {
d = *(innerGM_dist + jj) + dX;
d = *(innerGM_dist + jj) + dX;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix+1, iy, iz, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dX < d) {
d = *(innerGM_dist + jj) + dX;
d = *(innerGM_dist + jj) + dX;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix, iy-1, iz, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dY < d) {
d = *(innerGM_dist + jj) + dY;
}
d = *(innerGM_dist + jj) + dY;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d; }
}

j = sub2ind_3D(ix, iy+1, iz, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dY < d) {
d = *(innerGM_dist + jj) + dY;
d = *(innerGM_dist + jj) + dY;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
}
}

j = sub2ind_3D(ix, iy, iz-1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dZ < d) {
d = *(innerGM_dist + jj) + dZ;
}
d = *(innerGM_dist + jj) + dZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d; }
}

j = sub2ind_3D(ix, iy, iz+1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dZ < d) {
d = *(innerGM_dist + jj) + dZ;
d = *(innerGM_dist + jj) + dZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
}
}

Expand All @@ -504,107 +507,119 @@ int main(int argc, char* argv[]) {
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XY < d) {
d = *(innerGM_dist + jj) + dia_XY;
d = *(innerGM_dist + jj) + dia_XY;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix-1, iy+1, iz, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XY < d) {
d = *(innerGM_dist + jj) + dia_XY;
d = *(innerGM_dist + jj) + dia_XY;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix+1, iy-1, iz, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XY < d) {
d = *(innerGM_dist + jj) + dia_XY;
d = *(innerGM_dist + jj) + dia_XY;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix+1, iy+1, iz, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XY < d) {
d = *(innerGM_dist + jj) + dia_XY;
d = *(innerGM_dist + jj) + dia_XY;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix, iy-1, iz-1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_YZ < d) {
d = *(innerGM_dist + jj) + dia_YZ;
d = *(innerGM_dist + jj) + dia_YZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix, iy-1, iz+1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_YZ < d) {
d = *(innerGM_dist + jj) + dia_YZ;
d = *(innerGM_dist + jj) + dia_YZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix, iy+1, iz-1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_YZ < d) {
d = *(innerGM_dist + jj) + dia_YZ;
d = *(innerGM_dist + jj) + dia_YZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix, iy+1, iz+1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_YZ < d) {
d = *(innerGM_dist + jj) + dia_YZ;
d = *(innerGM_dist + jj) + dia_YZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix-1, iy, iz-1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XZ < d) {
d = *(innerGM_dist + jj) + dia_XZ;
d = *(innerGM_dist + jj) + dia_XZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix+1, iy, iz-1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XZ < d) {
d = *(innerGM_dist + jj) + dia_XZ;
d = *(innerGM_dist + jj) + dia_XZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix-1, iy, iz+1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XZ < d) {
d = *(innerGM_dist + jj) + dia_XZ;
d = *(innerGM_dist + jj) + dia_XZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix+1, iy, iz+1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XZ < d) {
d = *(innerGM_dist + jj) + dia_XZ;
d = *(innerGM_dist + jj) + dia_XZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

Expand All @@ -615,71 +630,79 @@ int main(int argc, char* argv[]) {
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XYZ < d) {
d = *(innerGM_dist + jj) + dia_XYZ;
d = *(innerGM_dist + jj) + dia_XYZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix-1, iy-1, iz+1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XYZ < d) {
d = *(innerGM_dist + jj) + dia_XYZ;
d = *(innerGM_dist + jj) + dia_XYZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix-1, iy+1, iz-1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XYZ < d) {
d = *(innerGM_dist + jj) + dia_XYZ;
d = *(innerGM_dist + jj) + dia_XYZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix+1, iy-1, iz-1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XYZ < d) {
d = *(innerGM_dist + jj) + dia_XYZ;
d = *(innerGM_dist + jj) + dia_XYZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix-1, iy+1, iz+1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XYZ < d) {
d = *(innerGM_dist + jj) + dia_XYZ;
d = *(innerGM_dist + jj) + dia_XYZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix+1, iy-1, iz+1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XYZ < d) {
d = *(innerGM_dist + jj) + dia_XYZ;
d = *(innerGM_dist + jj) + dia_XYZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix+1, iy+1, iz-1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XYZ < d) {
d = *(innerGM_dist + jj) + dia_XYZ;
d = *(innerGM_dist + jj) + dia_XYZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

j = sub2ind_3D(ix+1, iy+1, iz+1, size_x, size_y);
jj = *(voi_id_inv + j);
if (*(innerGM_step + jj) == step) {
border_detected = true;
if (*(innerGM_dist + jj) + dia_XYZ < d) {
d = *(innerGM_dist + jj) + dia_XYZ;
d = *(innerGM_dist + jj) + dia_XYZ;
if (*(innerGM_dist + kk) == 0. || d < *(innerGM_dist + kk)) {
*(innerGM_dist + kk) = d;
}
}

Expand All @@ -688,7 +711,6 @@ int main(int argc, char* argv[]) {
++size_determined;
++counter;
*(innerGM_step + kk) = step + 1;
*(innerGM_dist + kk) = d;
} else {
*(vox_id_undetermined + ii-counter) = i;

Expand All @@ -699,6 +721,19 @@ int main(int argc, char* argv[]) {
size_undetermined = nr_voi_gm - size_determined; // Update this outside
}

// // DEBUG
// nifti_image* nii_out3 = copy_nifti_as_int16(nii1);
// int16_t* nii_out3_data = static_cast<int16_t*>(nii_out3->data);
// for (int i = 0; i != nr_voxels; ++i) {
// *(nii_out3_data + i) = 0;
// }
// for (int ii = 0; ii != nr_voi_gm; ++ii) {
// int i = *(voi_id + ii);
// *(nii_out3_data + i) = *(innerGM_step + ii);
// }
// save_output_nifti(fout, "DEBUG_innerGM_step", nii_out3, false);


// DEBUG
nifti_image* nii_out = copy_nifti_as_float32(nii1);
float* nii_out_data = static_cast<float*>(nii_out->data);
Expand Down

0 comments on commit e132d4d

Please sign in to comment.