Skip to content

Commit

Permalink
update release 4.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mfroeling committed Dec 19, 2024
1 parent 96dcd1f commit 3e45d3c
Show file tree
Hide file tree
Showing 13 changed files with 4,147 additions and 1,278 deletions.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"cSpell.words": [
"apodization",
"Binarize",
"bspline",
"bval",
"bvec",
"centerpoints",
"Conv",
"dicom",
Expand All @@ -22,6 +25,8 @@
"Kutta",
"Martijn",
"Mathematica",
"megre",
"MESE",
"MUMRI",
"Nifti",
"onnx",
Expand All @@ -39,6 +44,7 @@
"Tractography",
"Transformix",
"transmural",
"tresh",
"Tversky",
"UNET",
"Westin",
Expand Down
2 changes: 1 addition & 1 deletion QMRITools/Kernel/ElastixTools.wl
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ RegisterCardiacData[{data_?ArrayQ, mask_?ArrayQ, vox:{_?NumberQ,_?NumberQ,_?Numb
(i++;RegisterData[{data[[#]],ConstantArray[maskr[[#]],size],vox},
OutputTransformation->False, PrintTempDirectory->False,FilterRules[{opts},Options[RegisterData]]])&/@slices
]
,ProgressIndicator[i,{0,Length[data]}]
,ProgressIndicator[i, {0,Length[data]}]
];
datar
]
Expand Down
43 changes: 23 additions & 20 deletions QMRITools/Kernel/FasciculationTools.wl
Original file line number Diff line number Diff line change
Expand Up @@ -116,43 +116,46 @@ Options[FindActivations] = Options[FindActivationsI] = {

SyntaxInformation[FindActivations] = {"ArgumentsPattern" -> {_, _., OptionsPattern[]}};

FindActivations[data_?MatrixQ, ops : OptionsPattern[]]:= FindActivationsI[data, ops]

FindActivations[data_, ops : OptionsPattern[]] := FindActivationsI[NormalizeData[data, NormalizeMethod -> "Volumes"], ops]

FindActivations[data_, mask_, ops : OptionsPattern[]] := FindActivationsI[
NormalizeData[data, DilateMask[mask, OptionValue[MaskDilation]], NormalizeMethod -> "Volumes"], ops]

FindActivationsI[data_, OptionsPattern[]] := Block[{met, sc, fr, start, stop, dat, act, mn ,tr, itt, back},

(*Get and check options*)
met = OptionValue[ThresholdMethod];
{sc, fr} = OptionValue[ActivationThreshold];
If[sc < 0 || fr > 1, Return[Message[FindActivations::tresh, sc, fr]]];
{start, stop} = OptionValue[IgnoreSlices];
itt = OptionValue[ActivationIterations];
back = OptionValue[ActivationBackground];

(*Get the options*)
{met, {sc, fr}, {start, stop}, itt, back ,output} = OptionValue[{ThresholdMethod, ActivationThreshold,
IgnoreSlices, ActivationIterations, ActivationBackground, ActivationOutput}];

(*set the threshold*)
If[sc < 0 || fr > 1, Return[Message[FindActivations::tresh, sc, fr]]];
{sc, fr} = Switch[met,
"Both", {sc, fr},
"Fraction", {0, fr},
"StandardDeviation", {sc, 1}
];

(*perform the activation finding in the selected slices*)
dat = RotateDimensionsLeft[Transpose[data[[start + 1 ;; -stop - 1]]]];
act = FindActC[dat, sc, fr, itt, back];
If[MatrixQ[data],
FindActC[data, sc, fr, itt, back],

(*create extra output if needed*)
If[OptionValue[ActivationOutput]=!="Activation",
{mn, tr, sc, fr} = RotateDimensionsRight[MeanThresh[dat, act, sc, fr, back]];
mn = ToPackedArray@ArrayPad[mn, {{start, stop}, {0, 0}, {0, 0}}, 0.];
tr = ToPackedArray@ArrayPad[Transpose[{tr, sc, fr}], {{start, stop}, {0, 0}, {0, 0}, {0, 0}}, 0.];
];
(*perform the activation finding in the selected slices*)
dat = RotateDimensionsLeft[Transpose[data[[start + 1 ;; -stop - 1]]]];
act = FindActC[dat, sc, fr, itt, back];

(*create extra output if needed*)
If[output=!="Activation",
{mn, tr, sc, fr} = RotateDimensionsRight[MeanThresh[dat, act, sc, fr, back]];
mn = ToPackedArray@ArrayPad[mn, {{start, stop}, {0, 0}, {0, 0}}, 0.];
tr = ToPackedArray@ArrayPad[Transpose[{tr, sc, fr}], {{start, stop}, {0, 0}, {0, 0}, {0, 0}}, 0.];
];

(*give output*)
act = SparseArray[ArrayPad[Round[Transpose[RotateDimensionsRight[act]]], {{start, stop}, {0, 0}, {0, 0}, {0, 0}}]];
(*give output*)
act = SparseArray[ArrayPad[Round[Transpose[RotateDimensionsRight[act]]], {{start, stop}, {0, 0}, {0, 0}, {0, 0}}]];

If[OptionValue[ActivationOutput]==="Activation", {act, data}, {act, data, mn ,tr}]
If[output==="Activation", {act, data}, {act, data, mn ,tr}]
]
]


Expand Down
6 changes: 4 additions & 2 deletions QMRITools/Kernel/GeneralTools.wl
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ FitGradientMap[{data_, msk_}, ord_, smp_] := Block[{val, dim, coor, fit, x, y, z

SyntaxInformation[MakeCoordinates] = {"ArgumentsPattern" -> {_, _}};

MakeCoordinates[dim_?VectorQ,vox_]:=vox RotateDimensionsRight@Array[{##}&,dim]
MakeCoordinates[dim_?VectorQ,vox_]:=vox RotateDimensionsRight@Array[{##}&, dim]

MakeCoordinates[dat_?ArrayQ,vox_]:=MakeCoordinates[Dimensions@dat,vox]

Expand Down Expand Up @@ -1148,9 +1148,11 @@ SyntaxInformation[MakeIntFunction] = {"ArgumentsPattern" -> {_,_.,_.,OptionsPatt

MakeIntFunction[dat_, opts:OptionsPattern[]] := MakeIntFunction[dat, {1,1,1}, 1, opts]

MakeIntFunction[dat_, vox_?VectorQ, opts:OptionsPattern[]] := MakeIntFunction[dat, vox, 1, opts]

MakeIntFunction[dat_, int_?IntegerQ, opts:OptionsPattern[]] := MakeIntFunction[dat, {1,1,1}, int, opts]

MakeIntFunction[dat_, vox_, int_?IntegerQ, opts:OptionsPattern[]] := Block[{dim, def, range},
MakeIntFunction[dat_, vox_?VectorQ, int_?IntegerQ, opts:OptionsPattern[]] := Block[{dim, def, range},
dim = Dimensions[dat][[;;3]];
range = Thread[{vox, vox dim}] - If[OptionValue[CenterVoxel]&&int>0, 0.5, 0] vox - If[OptionValue[CenterRange], 0.5, 0] dim;
def = 0. dat[[1,1,1]];
Expand Down
10 changes: 5 additions & 5 deletions QMRITools/Kernel/MaskingTools.wl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The mask is 3D, seg is 4D."


SplitSegmentations::usage =
"SplitSegmentations[segmentation] splits a lable mask from ITKsnap or slicer3D in seperate masks and label numbers.
"SplitSegmentations[segmentation] splits a lable mask from ITKsnap or slicer3D in separate masks and label numbers.
Output is masks and label numbers, {mask, labs}."

GetSegmentationLabels::usage =
Expand All @@ -74,7 +74,7 @@ SelectSegmentations::usage =
"SelectSegmentations[seg, labs] selects only the segmentations from seg with label number labs."

ReplaceSegmentations::usage =
"ReplaceSegmentations[seg, labs, new] relapaces the labels labs form the segmentation seg for labels new. Both labs and new should
"ReplaceSegmentations[seg, labs, new] replaces the labels labs form the segmentation seg for labels new. Both labs and new should
be lists of integers of the same size. If seg contains more labels then given in labs these will be replaced by 0."

SmoothSegmentation::usage =
Expand Down Expand Up @@ -118,7 +118,7 @@ MaskSmoothing::usage =
"MaskSmoothing is an options for Mask, SmoothMask and SmoothSegmentation, if set to True it smooths the mask, by closing holse and smoothing the contours."

MaskComponents::usage =
"MaskComponents is an option for Mask, SmoothMask and SmoothSegmentation. Determinse the amount of largest clusters used as mask."
"MaskComponents is an option for Mask, SmoothMask and SmoothSegmentation. Determines the amount of largest clusters used as mask."

MaskClosing::usage =
"MaskClosing is an option for Mask, SmoothMask and SmoothSegmentation. The size of the holes in the mask that will be closed."
Expand All @@ -137,7 +137,7 @@ SmoothIterations::usage =
(*Error Messages*)


Mask::tresh = "Given treshhold `1` value is not a valid input, must be a number for min treshhold only or a vector {min tresh, max tresh}."
Mask::tresh = "Given threshold `1` value is not a valid input, must be a number for min threshold only or a vector {min tresh, max tresh}."

MaskData::dim = "Dimensions are not equal, data: `1`, mask `2`."

Expand Down Expand Up @@ -520,7 +520,7 @@ SyntaxInformation[SmoothSegmentation] = {"ArgumentsPattern" -> {_, _., OptionsPa

SmoothSegmentation[maskIn_, opts:OptionsPattern[]] :=SmoothSegmentation[maskIn, All, opts]

SmoothSegmentation[maskIn_, what_, opts:OptionsPattern[]] := Block[{smooth,obj, md, masks, labs},
SmoothSegmentation[maskIn_, what_, opts:OptionsPattern[]] := Block[{smooth, obj, md, masks, labs},
md = ArrayDepth[maskIn];
(*split segmentations and make sparse if needed*)
If[md===3, {masks, labs} = SplitSegmentations[maskIn], masks = maskIn];
Expand Down
Loading

0 comments on commit 3e45d3c

Please sign in to comment.