...
 
Commits (2)
......@@ -24,6 +24,7 @@ XLSX ?= $(DATA)/$(SUBJECT)/patient.xlsx
# Only one of the following should be present
ELEC_POS_GARDEL ?= $(DATA)/$(SUBJECT)/elec/pos_vox.txt
ELEC_MM_GARDEL ?= $(DATA)/$(SUBJECT)/elec/pos_mm.txt
ELEC_ENDPOINTS ?= $(DATA)/$(SUBJECT)/elec/elec_endpoints.txt
ELEC_LABEL_SCHEMA ?= $(DATA)/$(SUBJECT)/elec/schema.txt
# }}}
......
......@@ -33,9 +33,16 @@ $(sd)/elec/labeled_elec-T1.nii.gz: $(sd)/elec/masked_elec-T1.nii.gz
# wildcard syntax below tests if file exists
ifneq ("$(wildcard $(ELEC_POS_GARDEL))", "")
# Coordinates from GARDEL
# Voxel coordinates from GARDEL
$(sd)/elec/seeg.xyz: $(ELEC_POS_GARDEL) $(sd)/elec/elec-$(elec_mode)_in_T1.nii.gz
python -m util.util transform_gardel_coords_to_tvb $< \
python -m util.util transform_gardel_coords_to_tvb ijk $< \
$(sd)/elec/elec-$(elec_mode).nii.gz \
$(sd)/elec/elec-$(elec_mode)_in_T1.nii.gz \
$(sd)/elec/elec-$(elec_mode)_to_T1.mat $@
else ifneq ("$(wildcard $(ELEC_MM_GARDEL))", "")
# MM coordinates from GARDEL
$(sd)/elec/seeg.xyz: $(ELEC_MM_GARDEL) $(sd)/elec/elec-$(elec_mode)_in_T1.nii.gz
python -m util.util transform_gardel_coords_to_tvb mm $< \
$(sd)/elec/elec-$(elec_mode).nii.gz \
$(sd)/elec/elec-$(elec_mode)_in_T1.nii.gz \
$(sd)/elec/elec-$(elec_mode)_to_T1.mat $@
......
......@@ -228,7 +228,8 @@ def gen_seeg_xyz_from_endpoints(scheme_fname, out_fname, transform_mat=None,
outfile.close()
def transform_gardel_coords_to_tvb(gardel_file, src_img_file, target_img_file, transform_mat, tvb_coords_file):
def transform_gardel_coords_to_tvb(units, gardel_file, src_img_file, target_img_file, transform_mat, tvb_coords_file):
assert units == 'mm' or units == 'ijk'
orig_coords = np.genfromtxt(gardel_file, names=True,
dtype=None,
usecols=(0, 1, 2, 3, 4))
......@@ -248,7 +249,10 @@ def transform_gardel_coords_to_tvb(gardel_file, src_img_file, target_img_file, t
target_coords = np.zeros((nsensors, 3))
for i in range(nsensors):
vox_src = [orig_coords[i]['x'], orig_coords[i]['y'], orig_coords[i]['z']]
ras_src = np.dot(src_img.affine, vox_src + [1])[0:3]
if units == 'ijk':
ras_src = np.dot(src_img.affine, vox_src + [1])[0:3]
else:
ras_src = vox_src
target_coords[i, :] = transform(ras_src, src_img_file, target_img_file, transform_mat)
with open(tvb_coords_file, 'w') as fl:
......