Skip to content

Commit 5b12a54

Browse files
committed
Speed up Jacobian det. computation
And compute the jacobian analysis on the warping field resulting from the registration (and not on the one transformed to the original space of the moving image).
1 parent 4967b99 commit 5b12a54

4 files changed

+10
-13
lines changed

eval_reg_with_jacobian.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,10 @@
6868
dz = np.reshape((ddf[2:-2, 2:-2, :-4, :] - 8*ddf[2:-2, 2:-2, 1:-3, :] + 8*ddf[2:-2, 2:-2, 3:-1, :] - ddf[2:-2, 2:-2, 4:, :])/12.0, [num_voxel, num_channel])
6969
J = np.stack([dx, dy, dz], 2)
7070

71-
det = []
72-
for voxel in range(num_voxel):
73-
J[voxel, 0, 0] = J[voxel, 0, 0] + 1
74-
J[voxel, 1, 1] = J[voxel, 1, 1] + 1
75-
J[voxel, 2, 2] = J[voxel, 2, 2] + 1
76-
n_array = J[voxel, :, :]
77-
det.append(np.linalg.det(n_array))
71+
J[:, 0, 0] = J[:, 0, 0] + 1
72+
J[:, 1, 1] = J[:, 1, 1] + 1
73+
J[:, 2, 2] = J[:, 2, 2] + 1
74+
det = np.linalg.det(J)
7875

7976
comparison = np.where(np.array(det) > 0, 0, np.array(det)) # all negatives values are there and positives become 0
8077
negative_dets = np.count_nonzero(comparison)

pipeline_bids_register_evaluate.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ then
109109
file_fx="${SUBJECT_ID}_${SES}_${FX_NAME}_proc"
110110
file_mov="${SUBJECT_ID}_${SES}_${MOV_NAME}_proc"
111111
file_mov_reg="${SUBJECT_ID}_${SES}_${MOV_NAME}_proc_reg_to_${FX_NAME}"
112-
file_warp="${SUBJECT_ID}_${SES}_${MOV_NAME}_warp_original_dim.nii.gz"
112+
file_warp="${SUBJECT_ID}_${SES}_${MOV_NAME}_proc_field_to_${FX_NAME}.nii.gz"
113113
sub_id="${SUBJECT_ID}_${SES}"
114114
else
115115
file_fx="${SES}_${FX_NAME}_proc"
116116
file_mov="${SES}_${MOV_NAME}_proc"
117117
file_mov_reg="${SES}_${MOV_NAME}_proc_reg_to_${FX_NAME}"
118-
file_warp="${SUBJECT_ID}_${SES}_${MOV_NAME}_warp_original_dim.nii.gz"
118+
file_warp="${SES}_${MOV_NAME}_proc_field_to_${FX_NAME}.nii.gz"
119119
sub_id="${SES}"
120120
fi
121121

pipeline_bids_register_evaluate_opt_affine.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ then
114114
file_fx="${SUBJECT_ID}_${SES}_${FX_NAME}_proc"
115115
file_mov="${SUBJECT_ID}_${SES}_${MOV_NAME}_proc"
116116
file_mov_reg="${SUBJECT_ID}_${SES}_${MOV_NAME}_proc_reg_to_${FX_NAME}"
117-
file_warp="${SUBJECT_ID}_${SES}_${MOV_NAME}_warp_original_dim.nii.gz"
117+
file_warp="${SUBJECT_ID}_${SES}_${MOV_NAME}_proc_field_to_${FX_NAME}.nii.gz"
118118
sub_id="${SUBJECT_ID}_${SES}"
119119
else
120120
file_fx="${SES}_${FX_NAME}_proc"
121121
file_mov="${SES}_${MOV_NAME}_proc"
122122
file_mov_reg="${SES}_${MOV_NAME}_proc_reg_to_${FX_NAME}"
123-
file_warp="${SUBJECT_ID}_${SES}_${MOV_NAME}_warp_original_dim.nii.gz"
123+
file_warp="${SES}_${MOV_NAME}_proc_field_to_${FX_NAME}.nii.gz"
124124
sub_id="${SES}"
125125
fi
126126

pipeline_bids_register_evaluate_two_steps.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ then
118118
file_fx="${SUBJECT_ID}_${SES}_${FX_NAME}_proc"
119119
file_mov="${SUBJECT_ID}_${SES}_${MOV_NAME}_proc"
120120
file_mov_reg="${SUBJECT_ID}_${SES}_${MOV_NAME}_proc_reg_to_${FX_NAME}"
121-
file_warp="${SUBJECT_ID}_${SES}_${MOV_NAME}_warp_original_dim.nii.gz"
121+
file_warp="${SUBJECT_ID}_${SES}_${MOV_NAME}_proc_field_to_${FX_NAME}.nii.gz"
122122
sub_id="${SUBJECT_ID}_${SES}"
123123
else
124124
file_fx="${SES}_${FX_NAME}_proc"
125125
file_mov="${SES}_${MOV_NAME}_proc"
126126
file_mov_reg="${SES}_${MOV_NAME}_proc_reg_to_${FX_NAME}"
127-
file_warp="${SES}_${MOV_NAME}_warp_original_dim.nii.gz"
127+
file_warp="${SES}_${MOV_NAME}_proc_field_to_${FX_NAME}.nii.gz"
128128
sub_id="${SES}"
129129
fi
130130

0 commit comments

Comments
 (0)