Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coregistration and exporting it to BIDS #647

Draft
wants to merge 49 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
8e6d19e
Option to change MRI fids to match digitized ones
Moo-Marc Feb 20, 2022
6631b47
Merge remote-tracking branch 'upstream/master' into Coordinates
Moo-Marc Feb 20, 2022
c40c8fe
can repeat new option by using remove first
Moo-Marc Feb 20, 2022
c3894ba
debugging
Moo-Marc Feb 20, 2022
b95846e
add option to process_refine
Moo-Marc Feb 20, 2022
cf5a141
improved report
Moo-Marc Feb 20, 2022
19fa381
improved scalp surface fit
Moo-Marc Feb 25, 2022
02f02d4
wip head surface & fit head points
Moo-Marc Mar 2, 2022
f126672
Merge remote-tracking branch 'upstream/master' into Coordinates
Moo-Marc Mar 22, 2022
6192ca5
Merge branch 'master' into Coordinates
Moo-Marc May 29, 2022
f09944c
threshold input for tess_isohead
Moo-Marc Jun 2, 2022
22864f7
Merge remote-tracking branch 'upstream/master' into Coordinates
Moo-Marc Jun 9, 2022
d3211ab
Merge remote-tracking branch 'upstream/master' into Coordinates
Moo-Marc Jun 16, 2022
8e862f9
Merge branch 'Coordinates' of github.com:Moo-Marc/brainstorm3 into Co…
Moo-Marc Jun 16, 2022
8846b76
Merge remote-tracking branch 'upstream/master' into Coordinates
Moo-Marc Jul 19, 2022
c778b8a
head shape from spatial gradient threshold
Moo-Marc Aug 9, 2022
529fb44
small fix for old pos files
Moo-Marc Aug 9, 2022
5931718
cleanup
Moo-Marc Aug 9, 2022
9db6c9e
Merge branch 'HeadPoints' into Coordinates
Moo-Marc Aug 9, 2022
6133b7f
Fix indentation
ftadel Aug 10, 2022
8f967a9
Recompute distance dynamically
ftadel Aug 10, 2022
31e3177
Added popup menu for color-coded dots
ftadel Aug 10, 2022
b2b4a7a
wip, head points as patch
Moo-Marc Aug 10, 2022
7a4cbed
Further head point modifications, merged with Francois' changes
Moo-Marc Aug 10, 2022
2e8bc09
cleanup
Moo-Marc Aug 10, 2022
517f509
Merge branch 'HeadPoints' into Coordinates
Moo-Marc Aug 11, 2022
34ef50b
Merge remote-tracking branch 'upstream/master' into Coordinates
Moo-Marc Aug 11, 2022
74e02da
Enforce target (0,0,0) only when the axes are visible
ftadel Aug 12, 2022
89a9b98
Disabling camera target at (0,0,0)
ftadel Aug 12, 2022
f510e90
Get rid of normr
ftadel Aug 12, 2022
382ca44
Moved popup menu to Channel submenu (Figure is independent from the d…
ftadel Aug 12, 2022
9faac45
colorbar fix
Moo-Marc Aug 31, 2022
bd2b22a
Merge branch 'HeadPoints' into Coordinates
Moo-Marc Sep 1, 2022
9e6f026
Merge remote-tracking branch 'upstream/master' into Coordinates
Moo-Marc Nov 7, 2022
90b4dac
tweaks to manual registration figure, head points distance coloring
Moo-Marc Nov 18, 2022
fb08e81
Merge branch 'master' into Coordinates
Moo-Marc Nov 18, 2022
a91ac60
fix head point distance coloring & add manual registration reset button
Moo-Marc Nov 18, 2022
ea3ea6d
small code cleaning
Moo-Marc Nov 18, 2022
e8ceedb
undo adding head points as figure surface
Moo-Marc Nov 22, 2022
97bef91
Merge remote-tracking branch 'upstream/master' into Coordinates
Moo-Marc Nov 22, 2022
811e941
Merge branch 'HeadPoints' into Coordinates and further fixes
Moo-Marc Nov 25, 2022
af062b3
minor fix to adjust coordinates scs option
Moo-Marc Nov 28, 2022
242f9d5
compat fix
Moo-Marc Nov 28, 2022
be59842
wip exporting registration to BIDS
Moo-Marc Dec 2, 2022
9f3be2b
wip coregistration
Moo-Marc Jan 16, 2023
e9d0e46
adding coregistration export for BIDS
Moo-Marc Sep 27, 2023
301a489
Merge branch 'master' into Coordinates
Moo-Marc Sep 27, 2023
6ab9794
fix apply digitized fids to MRI
Moo-Marc Sep 27, 2023
ca6c152
coregistration branch cleanup
Moo-Marc Sep 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions toolbox/anatomy/cs_convert.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
% DESCRIPTION: https://neuroimage.usc.edu/brainstorm/CoordinateSystems
% - voxel : X=left>right, Y=posterior>anterior, Z=bottom>top
% Coordinate of the center of the first voxel at the bottom-left-posterior of the MRI volume: (1,1,1)
% - mri : Same as 'voxel' but in millimeters instead of voxels: mriXYZ = voxelXYZ * Voxsize
% - mri : Same as 'voxel' but in meters (not mm here) instead of voxels: mriXYZ = voxelXYZ * Voxsize
% - scs : Based on: Nasion, left pre-auricular point (LPA), and right pre-auricular point (RPA).
% Origin: Midway on the line joining LPA and RPA
% Axis X: From the origin towards the Nasion (exactly through)
Expand Down Expand Up @@ -122,7 +122,7 @@
scs2captrak = [tCapTrak.R, tCapTrak.T; 0 0 0 1];
end

% ===== CONVERT SRC => MRI =====
% ===== CONVERT SRC => MRI (m) =====
% Evaluate the transformation to apply
switch lower(src)
case 'voxel'
Expand Down Expand Up @@ -174,7 +174,7 @@
error(['Invalid coordinate system: ' src]);
end

% ===== CONVERT MRI => DEST =====
% ===== CONVERT MRI (m) => DEST =====
% Evaluate the transformation to apply
switch lower(dest)
case 'voxel'
Expand Down
32 changes: 22 additions & 10 deletions toolbox/anatomy/mri_histogram.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
% |- max[4] : array of the 4 most important maxima (structure)
% | |- x : intensity of the given maximum
% | |- y : amplitude of this maximum (number of MRI voxels with this value)
% | |- power : difference of this maximum and the adjacent minima
% | |- power : difference of this maximum and the adjacent minimum
% |- min[4] : array of the 3 most important minima (structure)
% | |- x : intensity of the given minimum
% | |- y : amplitude of this minimum (number of MRI voxels with this value)
% | |- power : difference of this minimum and the adjacent maxima
% | |- power : difference of this minimum and the adjacent maximum
% |- bgLevel : intensity value that separates the background and the objects (estimation)
% |- whiteLevel : white matter threshold
% |- intensityMax : maximum value in the volume
Expand Down Expand Up @@ -179,7 +179,7 @@
Histogram.max(i).y = histoY(maxIndex(i));
if(length(minIndex)>=1)
% If there is at least a minimum, power = distance between
% maximum and adjacent minima
% maximum and adjacent minimum
Histogram.max(i).power = histoY(maxIndex(i)) - (histoY(minIndex(max(1, i-1))) + histoY(minIndex(min(length(minIndex), i))))./2;
else
% Else power = maximum value
Expand Down Expand Up @@ -237,12 +237,12 @@
elseif (length(cat(1,Histogram.max.x)) < 2)
Histogram.bgLevel = defaultBg;
Histogram.whiteLevel = defaultWhite;
% Else if there is more than one maxima :
% Else if there is more than one maximum :
else
% If the highest maxima is > (3*second highest maxima) :
% it is a background maxima : use the first minima after the
% background maxima as background threshold
% (and if this minima exist)
% If the highest maximum is > (3*second highest maximum) :
% it is a background maximum : use the first minimum after the
% background maximum as background threshold
% (and if this minimum exist)
[orderedMaxVal, orderedMaxInd] = sort(cat(1,Histogram.max.y), 'descend');
if ((orderedMaxVal(1) > 3*orderedMaxVal(2)) && (length(Histogram.min) >= orderedMaxInd(1)))
Histogram.bgLevel = Histogram.min(orderedMaxInd(1)).x;
Expand All @@ -251,7 +251,20 @@
Histogram.bgLevel = defaultBg;
end
end


case 'headgrad'
dX = mean(diff(Histogram.smoothFncX));
%Deriv = gradient(Histogram.smoothFncY, dX);
%SecondDeriv = gradient(Deriv, dX);
RemainderCumul = Histogram.smoothFncY ./ cumsum(Histogram.smoothFncY, 2, 'reverse');
DerivRC = gradient(RemainderCumul, dX);
%DerivRC2 = Deriv ./ cumsum(Histogram.smoothFncY, 2, 'reverse');
%figure; plot(Histogram.smoothFncX', [RemainderCumul', DerivRC']); legend({'hist/remaining', 'derivative'});
% Pick point where things flatten.
Histogram.bgLevel = Histogram.smoothFncX(find(DerivRC > -0.005 & DerivRC < DerivRC([2:end, end]), 1) + 2);
% Can't get white matter with gradient.
Histogram.whiteLevel = 0;

case 'brain'
% Determine an intensity value for the background/gray matter limit
% and the gray matter/white matter level
Expand Down Expand Up @@ -328,5 +341,4 @@

end



Loading