Skip to content

Commit

Permalink
For 2 bad markers use ICP not rot3dfit
Browse files Browse the repository at this point in the history
When there are two adjacent bad markers removed, rot3dfit does not work
well (see #7). Therefore an alternative point to point ICP method has
been implemented to give an alternative transformation matrix. This
seems to give an identical solution compared with rot3dfit (with 5
markers) and much better solution for 3 markers. Workaround for #7.
Thoughts @paulsowman?
  • Loading branch information
neurofractal committed Oct 3, 2018
1 parent 662c177 commit cbbb4d2
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions MEMES3.m
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,22 @@ function MEMES3(dir_name,elpfile,hspfile,confile,mrkfile,path_to_MRI_library,bad
fids_2_use = shape.fid.pnt(4:end,:);
% Now take out the bad marker(s) when you realign
fids_2_use(badcoilpos,:) = [];

[R,T,Yf,Err] = rot3dfit(markers,fids_2_use);%calc rotation transform
meg2head_transm = [[R;T]'; 0 0 0 1];%reorganise and make 4*4 transformation matrix

% If there are two bad coils use the ICP method, if only one use
% rot3dfit as usual
disp('Performing re-alignment');
grad_trans = ft_transform_geometry_PFS_hacked(meg2head_transm,grad_con); %Use my hacked version of the ft function - accuracy checking removed not sure if this is good or not
grad_trans.fid = shape; %add in the head information

if length(bad_coil) == 2
[R, T, err, dummy, info] = icp(fids_2_use', markers','Minimize', 'point');
meg2head_transm = [[R T]; 0 0 0 1];%reorganise and make 4*4 transformation matrix
grad_trans = ft_transform_geometry_PFS_hacked(meg2head_transm,grad_con); %Use my hacked version of the ft function - accuracy checking removed not sure if this is good or not
grad_trans.fid = shape; %add in the head information
else
[R,T,Yf,Err] = rot3dfit(markers,fids_2_use);%calc rotation transform
meg2head_transm = [[R;T]'; 0 0 0 1];%reorganise and make 4*4 transformation matrix
grad_trans = ft_transform_geometry_PFS_hacked(meg2head_transm,grad_con); %Use my hacked version of the ft function - accuracy checking removed not sure if this is good or not
grad_trans.fid = shape; %add in the head information
end
end

% Create figure to view relignment
Expand Down

4 comments on commit cbbb4d2

@paulsowman
Copy link

@paulsowman paulsowman commented on cbbb4d2 Oct 3, 2018 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neurofractal
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could.. but rot3dfit is robust for most situations.. point to point ICP requires more testing IMO. I'll open a new issue for this.

@paulsowman
Copy link

@paulsowman paulsowman commented on cbbb4d2 Oct 7, 2018 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neurofractal
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - only 1 iteration required versus 50 for ICP

Please sign in to comment.