Functions¶
-
createSimpleMPRWorldCoordinates
(nii)¶ Convenience Wrapper for the MPRWorldCoordinate Class by Florian Bernard
Usage
[mpr] = createSimpleMPRWorldCoordinates(nii)Input
- nii – NiftiModality object to visualize as multi-planar-reformatting (MPR)
Output
- mpr – Handle to MPR
-
determineElectrodeType
(peakDistances)¶ gets the most suitable electrode type based on the euclidean distance between detected and specified peaks in the collected data. Data should should be provided in the form of the file ‘electrodeGeometries.mat’.
Usage
[electStruct, rms, d] = determineElectrodeType(peakDistances)Input
- peakDistances – The peak distances between the signals, provided by the inserted data sheet.
Outputs
- electStruct – Electrode Type.
- rms – Root-mean-square of the distance between the electrode signals.
- d – Euclidian distance to the closest electrode prototype
-
extractBrainConvHull
(niiCT)¶ Extracts the convex hull of the brain out of a CT image
Usage
[convHullBrainMask, roughBrainMask] = extractBrainConvHull(niiCT)Input
- niiCT – NiftiMod object of a post-operative CT image
Outputs
- convHullBrainMask – Estimated mask of the convex hull of the brain
- roughBrainMask – Estimated rough brain mask wich may contain inaccuracies
-
extractElectrodePointclouds
(niiCT, varargin)¶ extractElectrodePointclouds - Preprocess CT Data for Electrode Artifacts
Usage
[elecsPointcloudStruct, brainMask] = extractElectrodePointclouds(niiCT, varargin)Inputs
niiCT – NiftiMod object of a post-operative CT image
varargin – Variable Argument:
noMask: For phantom studies where no brain is present in data brainMask: For manually providing brain mask
(binary segmentation image file path)
- medtronicXMLPlan: Path to XML file defining a Medtronic Stealth Station
S7 trajectory plan
metalThreshold: CT metal threshold value.
Outputs
- elecsPointcloudStruct – Create output struct and try to associate electrodes from xml definition if given
- brainMask – Define the brain area
-
fitParamPolyToSkeleton
(skeleton, degree)¶ Fits a parameterized polynomial [0,1] -> R^3 to a skeleton point cloud
Usage
[r3polynomial, avgTperMm] = fitParamPolyToSkeleton(skeleton, degree)Inputs
- skeleton – 3 x N skeleton pointcloud
- degree – Degree of fitted polynomial (DEFAULT: 3)
Outputs
- r3polynomial – Coefficient matrix of fitted polynomial
- avgTperMm – Average “t” per millimeter along the arc length of the polynomial
-
getIntensityPeaks
(intensityProfile, skelScaleMm, filterIdxs)¶ Get peaks, respectively center points, at threshold below the peaks from 1D intensity profile. Expected peakWaveCenter number is 4 for now (needs update to support electrodes with more ring contacts)!
Usage
[peakLocs, peakWaveCenters, peakValues, threshIntensityProfile, threshold, contactAreaCenter, contactAreaWidth, xrayMarkerAreaCenter, xrayMarkerAreaWidth] = getIntensityPeaks(intensityProfile, skelScaleMm, filterIdxs)Inputs
- intensityProfile – 1D Intensity Profile
- skelScaleMm – Estimated millimetric scale
- filterIdxs – Finds the linear index of the millimetric scale
Outputs
- peaklocs – 1D peak locations
- peakWaveCenters – 1D peak wave center locations
- peakValues – Peak values
- threshIntensityProfile – Thresholded intensity profile
- threshold – Threshold
- contactAreaCenter – Center of the assumed contact area
- contactAreaWidth – Width of the assumed contact area
- xrayMarkerAreaCenter – Center of the xray marker (if any)
- xrayMarkerAreaWidth – Width of the xray maker (if any)
-
invPolyArcLength3
(polyCoeff, arcLength)¶ Numerically calculate the parameter (t) of parameterized [0,1] -> R^3 polynomial given an arc length (measured from 0) i.e. find the corresponding t to an arc length (e.g. given in [mm] from the origin), or in other words numerically invert polyArcLength3
Usage
t = invPolyArcLength3(polyCoeff, arcLength)Inputs
- polyCoeff – Coefficient matrix
- arcLength – The arc length is defined as the integral of the norm of the derivatives of the parameterized equations, given in mm.
Output
- t – Parameter of the polynomial
-
largestConnCompSliceWise
(img3d)¶ Outputs a Binary mask of the largest connected component within that volume, computed slice wise 2d and stacked
Usage
binaryMask = largestConnCompSliceWise(img3d)Input
- img3d – An image volume
Output
- binaryMask – Binary mask of the largest connected component within that volume, computed slice wise 2d and stacked
-
oor
(r3polyToUse, STEP_SIZE, XGrid, YGrid, interpolationF)¶ OOR - Optimal Oblique Resampling along a given polynonimal
Usage
[improvedSkeleton, medIntensity, orthIntensVol, orthSamplePointsVol, skelScaleMm] = oor(r3polyToUse, STEP_SIZE, XGrid, YGrid, interpolationF)Inputs
- r3polyToUse – Polynomial coefficient matrix
- STEP_SIZE – Step size along polynomial
- XGrid – Grid to sample perpentidular to polyonial (x)
- YGrid – Grid to sample perpentidular to polyonial (y)
- interpolationF – An interpolater fitted to point cloud (see scatteredInterpolant)
Outputs
- improvedSkeleton – Newly determined skeleton point cloud after re-sampling
- medIntensity – Median intensity along the polynomial
- orthIntensVol – Intensity volume stacked as orthogonal matrix
- orthSamplePointsVol – Sampling points stacked as orthogonal matrix
- skelScaleMm – Estimated millimetric scale
-
plotIntensityProfileAndPeaks
(intensityProfile, skelScaleMm)¶ Usage
plotIntensityProfileAndPeaks(intensityProfile, skelScaleMm)Inputs
- intensityProfile – a 1D Intensity profile
- skelScaleMm – Estimated scale (mm per intensity sample)
-
polyArcLength3
(polyCoeff, lowerLimit, upperLimit)¶ Usage
arcLength = polyArcLength3(polyCoeff, lowerLimit, upperLimit)Inputs
- polyCoeff – Coefficient matrix
- lowerLimit – Lower limit, taken as scalar or vector input. If put in as a vector, arc lengths are returned for all pairs of intervals between the lower and upper limit.
- upperLimit – Upper limit, taken as scalar or vector input. If put in as a vector, arc lengths are returned for all pairs of intervals between the upper and lower limit.
Output
- arcLength – The arc length is defined as the integral of the norm of the derivatives of the parameterized equations.
-
polyval3
(polyCoeffs, evalAt)¶ evaluate an (independent component) polynomial in R3
Usage
val = polyval3(polyCoeffs, evalAt)Inputs
- polyCoeffs – Coefficient matrix
- evalAt – a polynomial in R^3
Output
- val – a polynomial in R
-
refitElec
(initialPoly, pointCloudWorld, voxelValues, varargin)¶ refits a previously extracted corse electrode model using optimal oblique sampling to increase accuracy and enable automatic contact localisation. Intital refitting (“2nd pass” is followed by a final “3rd pass” to calibrate the point of origin / zero according to the detected contacts) Usage
[refitReZeroedElecMod, filteredIntensity, skelScaleMm] = refitElec(initialPoly, pointCloudWorld, voxelValues, varargin)Inputs
- initialPoly – Dx3 double, R3 ploynomial coeffecients
- pointCloudWorld – Nx3 double, point cloud of sourounding voxels in respective coordinate system
- voxelValues – Nx1 double, voxels intensitiy values (1:1 to pointCloudWorld)
- varargin – options cell
Outputs
- refitReZeroedElecMod – polynomialElectrodeModel Object with the refitted and rezeored elec model, including reference to elecInfo etc.
- filteredIntensity – 1D intensity profile
- skelScaleMm – estimated mm per skeleton step