Skip to content

Commit

Permalink
Merge pull request #93 from soichih/master
Browse files Browse the repository at this point in the history
Added code to clip out-of-dwi fiber coordinates
  • Loading branch information
francopestilli authored Dec 14, 2018
2 parents 5ec160d + 1e1e017 commit c6d514a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions life/fe/feConnectomeEncoding.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@

% Compute voxels
voxel_coord = round(fibers) + 1;

% Clip coordinates to within imgsize
voxel_coord(voxel_coord<1)=1;
voxel_coord(1, voxel_coord(1,:)>imgsize(1))=imgsize(1);
voxel_coord(2, voxel_coord(2,:)>imgsize(2))=imgsize(2);
voxel_coord(3, voxel_coord(3,:)>imgsize(3))=imgsize(3);

cols = sub2ind(imgsize, voxel_coord(1,:)', voxel_coord(2,:)', voxel_coord(3,:)');

% Compute atoms
Expand Down
9 changes: 9 additions & 0 deletions life/fe/feConnectomeSetDwi.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
dwiGet(dwi, 'diffusion bvals'));
fe = feSet(fe, sprintf('bvecs indices %s',tag), ...
dwiGet(dwi, 'diffusionimagenums'));


dim = dwi.nifti.dim;
coords = fe.roi.coords;
coords(coords<1)=1;
coords(coords(:,1)>dim(1), 1)=dim(1);
coords(coords(:,2)>dim(2), 2)=dim(2);
coords(coords(:,3)>dim(3), 3)=dim(3);
fe.roi.coords = coords;

% Extract the dwi signal at the coordinates of the connectome
fe = feSet(fe, sprintf('diffusion signal image %s',tag), ...
Expand Down
1 change: 0 additions & 1 deletion life/utility/fefgGet.m
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@
% matrix of integers.
% val = round(horzcat(fg.fibers{:})');
val = round(horzcat(fg.fibers{:})')+1;
val(val<1)=1;
val = unique(val,'rows');

case {'allimagecoords'}
Expand Down

0 comments on commit c6d514a

Please sign in to comment.