Skip to content

Commit 936abde

Browse files
committed
bugfix tracto
1 parent 8bc81db commit 936abde

File tree

9 files changed

+196930
-1692
lines changed

9 files changed

+196930
-1692
lines changed

QMRITools/Documentation/English/Guides/NeuralNetworkTools.nb

Lines changed: 513 additions & 0 deletions
Large diffs are not rendered by default.

QMRITools/Documentation/English/ReferencePages/Symbols/NormalizeFasciculationData.nb

Lines changed: 509 additions & 0 deletions
Large diffs are not rendered by default.

QMRITools/Documentation/English/ReferencePages/Symbols/TopKLossLayer.nb

Lines changed: 520 additions & 0 deletions
Large diffs are not rendered by default.

QMRITools/Kernel/MuscleBidsTools.wl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,7 +2110,7 @@ MuscleBidsProcessI[{folIn_, folOut_}, datType_, verCheck_] := Block[{
21102110
adci = 1000 adci;
21112111
outTypes = Join[{"adci", "fri", "s0i"}, outTypes];
21122112
];
2113-
2113+
21142114
(*perform the actual tensor calculation*)
21152115
(*-----*)AddToLog["Starting tensor calculation", 4];
21162116
{tens, s0, out} = Quiet@TensorCalc[data, grad, val, coil, FullOutput->True,
@@ -2928,18 +2928,19 @@ MuscleBidsTractographyI[{folIn_, folOut_}, {datType_, allType_}, verCheck_, met_
29282928
(* Import stop files *)
29292929
stop = (
29302930
{stop, voxs} = ImportNii[#];
2931-
debugBids["Voxel sizes: ", {voxs, vox}];
2932-
If[voxs=!=vox, RescaleData[stop, {voxs, vox}], stop]
2931+
debugBids["Voxel sizes: ", {voxs, vox , Dimensions@stop}];
2932+
If[voxs===vox, stop, PadToDimensions[RescaleData[stop, {voxs, vox}], dim]]
29332933
)& /@ stopfile;
2934-
stop = Transpose[{stop, tractStopVal}];
29352934
debugBids["Data dimensions: ", Dimensions/@Join[stop, {tens}]];
2935+
stop = Transpose[{stop, tractStopVal}];
2936+
29362937

29372938
(* Perform tractography *)
29382939
(*-----*)AddToLog[{"Starting the whole volume tractography"}, 4];
29392940
{tracts, seeds} = FiberTractography[tens, vox, stop,
29402941
InterpolationOrder -> 0, StepSize -> step, Method -> "RK4",
29412942
MaxSeedPoints -> If[seed<1, Scaled[seed], seed],
2942-
FiberLengthRange -> len, FiberAngle -> ang, TractMonitor -> False,
2943+
FiberLengthRange -> len, FiberAngle -> ang, TractMonitor -> True,
29432944
TensorFlips -> flip, TensorPermutations -> per, Parallelization -> True
29442945
];
29452946

QMRITools/Kernel/SegmentationTools.wl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ SplitDataForSegmentation[data_?ArrayQ, seg_?ArrayQ, what_?StringQ, opt:OptionsPa
711711
SplitDataForSegmentation[data_?ArrayQ, opt:OptionsPattern[]] := SplitDataForSegmentation[data, "Legs", opt]
712712

713713
SplitDataForSegmentation[data_?ArrayQ, what_?StringQ, opt:OptionsPattern[]] := Block[{
714-
dim, whatSide, side, whatPos, pos, dat, right, left, cut, pts, loc, time, mon, dev
714+
dim, whatSide, side, whatPos, pos, dat, right, left, cut, pts, loc, time, mon, dev, over
715715
},
716716
dim = Dimensions[data];
717717
{mon, dev} = OptionValue[{Monitor, TargetDevice}];
@@ -787,7 +787,8 @@ SplitDataForSegmentation[data_?ArrayQ, what_?StringQ, opt:OptionsPattern[]] := B
787787
dat = Switch[whatSide,
788788
(*both sides which need to be split*)
789789
"Both",
790-
{cut, over} = ClassifyData[data, "ShoulderPosition"];
790+
(*{cut, over} = ClassifyData[data, "ShoulderPosition"];*)
791+
{cut, over} = Round[{0.5, 0.1} Last@Dimensions[data]];
791792
{right, left, cut} = CutData[data, {cut, over}];
792793
{
793794
{right, {"Shoulder", {1, dim[[1]]}}, {"Right", {1, cut + over}}},

QMRITools/Kernel/SpectroTools.wl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,12 @@ SpectraSimulator[]:=Block[{},DynamicModule[{
17791779
ns = Round[Min[{ns,nsamp dw/dw2-ni}]];
17801780

17811781
fid1 = ChangeDwellTimeFid[fidsT[[ni+1;;]],dw,dw2][[;;ns]];
1782-
sig = (Max[Abs[fid1]]/snr)/Sqrt[2];
1782+
(* Define reference values *)
1783+
bwRef = 5000.;
1784+
nRef = 512.;
1785+
(* Calculate scaled sigma *)
1786+
(* We use the Max of the original fidsT to keep the SNR relative to the source signal *)
1787+
sig = (Max[Abs[fid1]] / snr) * Sqrt[bw / bwRef] * Sqrt[nRef / ns] / Sqrt[2];
17831788

17841789
If[lfid=!=Length[fid1]||sigi=!=sig,
17851790
lfid = Length[fid1];
@@ -1816,7 +1821,9 @@ SpectraSimulator[]:=Block[{},DynamicModule[{
18161821
timep = time + (te-ph1s) / 1000;
18171822
{pmin, pmax} = {Min[{pmin, Max[ppm]}], Max[{pmax, Min[ppm]}]};
18181823

1819-
Grid[{{
1824+
Grid[{
1825+
{Style[{sig, StandardDeviation[noise1], StandardDeviation[noise5]},Black]},
1826+
{
18201827
(*{Total@Re@fidP,Re@First@fidP,Total@Abs@ShiftedFourier@fidP,sig,simTrigger},
18211828
peakSel,*)
18221829
Show[
@@ -1829,7 +1836,8 @@ SpectraSimulator[]:=Block[{},DynamicModule[{
18291836
If[ap==="None", Graphics[], ListLinePlot[Transpose@{timei,maxFid apodizeFun[timei,ap]}, PlotStyle->{Darker@Green, Dashed}]]
18301837
]
18311838
},{
1832-
PlotSpectra[ppm, specP, PlotRange -> {If[pran==="Automatic", Full, {pmin, pmax}], {-0.2, 1.2} maxSpec},
1839+
PlotSpectra[ppm,
1840+
ShiftSpectra[specP, {dw, gyro}, off] (*specP*), PlotRange -> {If[pran==="Automatic", Full, {pmin, pmax}], {-0.2, 1.2} maxSpec},
18331841
GridLineSpacing -> 5, AspectRatio -> .5, Method -> met, ImageSize -> psize]
18341842
}}, Background -> White]
18351843

@@ -1943,7 +1951,7 @@ SpectraSimulator[]:=Block[{},DynamicModule[{
19431951

19441952
ControlPlacement->Left,
19451953
SaveDefinitions->True,
1946-
TrackedSymbols:>{bw, ns, te, timeshift, eps, gam, f, ph0, ph0s, ph1s, off,
1954+
TrackedSymbols:>{bw, ns, te, timeshift, eps, gam, f, ph0, ph0s, ph1s, off, psize,
19471955
snr, pad, ap, show, pran, pmin, pmax, met, simTrigger}
19481956
];
19491957

QMRITools/PacletInfo.wl

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
PacletObject[<|
44
"Name" -> "QMRITools",
5-
"Version" -> "4.6.0",
5+
"Version" -> "4.6.1",
66
"WolframVersion" -> "14.0+",
77
"SystemID" -> All,
8-
8+
99
"Description" -> "Toolbox for Quantitative MRI.",
1010
"Creator" -> "Martijn Froeling <m.froeling@gmail.com>",
1111
"Support" -> "https://github.com/mfroeling/QMRITools",
@@ -17,7 +17,7 @@ PacletObject[<|
1717
{"Kernel", "Root" -> "Kernel", "Context" -> "QMRITools`"},
1818
{"Documentation", "Language" -> "English", "MainPage" -> "Guides/QMRITools"},
1919

20-
(* ---- OS independent assest ---- *)
20+
(* ---- OS independent assets ---- *)
2121

2222
(*files that need to be included in the build*)
2323
{"Asset", "Root" -> "Resources", "Assets" -> {{"Logo", "icon.png"}}},
@@ -29,28 +29,26 @@ PacletObject[<|
2929
{"Asset", "Root" -> "Resources", "Assets" -> {{"GradientTool", "GradientGUI-v14.cdf"}}},
3030

3131
(*Neural Networks segmentation*)
32-
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"SegThighMuscle", "Muscles_leg_upper.wlnet"}}},
33-
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"SegLegMuscle", "Muscles_leg_lower.wlnet"}}},
34-
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"SegLegBones", "Bones_leg_full.wlnet"}}},
35-
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"SegShoulderMuscle", "Muscles_shoulder.wlnet"}}},
32+
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"SegShoulderMuscle", "N2_Shoulder.wlnet"}}},
33+
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"SegThighMuscle", "N5_UpperLeg.wlnet"}}},
34+
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"SegLegMuscle", "N6_LowerLeg.wlnet"}}},
3635

37-
(*Neural Networks clasification*)
38-
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"LegSide", "Leg_side_full.wlnet"}}},
39-
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"LegPosition", "Leg_pos_full.wlnet"}}},
40-
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"ShoulderSide", "Shoulder_side.wlnet"}}},
41-
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"ShoulderPosition", "Shoulder_cut.wlnet"}}},
36+
(*Neural Networks classification*)
37+
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"LegSide", "Side_Leg.wlnet"}}},
38+
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"LegPosition", "Pos_Leg.wlnet"}}},
39+
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"ShoulderSide", "Side_Shoulder.wlnet"}}},
4240

4341
(*Segmentation labels*)
44-
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"BonesLegLabels", "Bones_leg.txt"}}},
42+
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"MusclesShoulderLabels", "N2_Shoulder.txt"}}},
43+
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"MusclesHipLabels", "N4_Hip.txt"}}},
44+
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"MusclesLegUpperLabels", "N5_UpperLeg.txt"}}},
45+
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"MusclesLegLowerLabels", "N6_LowerLeg.txt"}}},
46+
4547
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"MusclesLegLabels", "Muscles_leg.txt"}}},
4648
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"MusclesLegAllLabels", "Muscles_leg_all.txt"}}},
47-
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"MusclesLegHipLabels", "Muscles_leg_hip.txt"}}},
48-
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"MusclesLegLowerLabels", "Muscles_leg_lower.txt"}}},
49-
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"MusclesLegUpperLabels", "Muscles_leg_upper.txt"}}},
50-
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"MusclesShoulderAllLabels", "Muscles_shoulder_full.txt"}}},
51-
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"MusclesShoulderLabels", "Muscles_shoulder_single.txt"}}},
49+
{"Asset", "Root" -> "NeuralNetworks", "Assets" -> {{"MusclesShoulderAllLabels", "Muscles_shoulder.txt"}}},
5250

53-
(* ---- OS dependant assest ---- *)
51+
(* ---- OS dependant assets ---- *)
5452

5553
(*Windows*)
5654
{"Asset", "SystemID" -> "Windows-x86-64", "Root" -> "Applications/Windows-x86-64", "Assets" -> {{"Elastix", "elastix.exe"}}},

0 commit comments

Comments
 (0)