TISI: TISI: Trace Identification Through Separation for Improvement

View source: R/userFunctions.R

TISIR Documentation

TISI: Trace Identification Through Separation for Improvement

Description

Combines all other functions to allow the user to digitize one image. This function allows for input of specific known envelopes set manually using the shiny application along with this function. All parameters are still adjustable like in TIS to allow for attempts to digitize more then one type of image. Recommended to experiment with all individual functions, then set parameters in this function to do the total digitization.

Usage

TISI(
  imageName,
  fileLoc,
  pathToWorkingDir = "~/",
  improvement = FALSE,
  HDVcheck = FALSE,
  plotPNG = TRUE,
  saveData = FALSE,
  improveTopBottomCuts = NA,
  improveTTopEnvelope = NA,
  improveBTopEnvelope = NA,
  improveTBottomEnvelope = NA,
  improveBBottomEnvelope = NA,
  improveTopEnvelopeStartEnd = NA,
  improveBottomEnvelopeStartEnd = NA,
  trimAmountTop = 100,
  trimAmountBottom = 50,
  trimAmountLeft = 2,
  trimAmountRight = 2,
  beta0 = -2.774327,
  beta1 = 51.91687,
  cutoffProbability = 0.5,
  NADefault = 0,
  FilterBright = c(13, 13),
  FilterNonBright = c(8, 8),
  methodBright = "delation",
  methodNonBright = "delation",
  thresholdBright = 0.8,
  thresholdNonBright = 0.5,
  peakPercFromEdge = 2,
  peakPercentFromEdgeLeftSide = 25,
  cutPercentage = 2,
  shortestAllowedSeqOfZeros = 25,
  tripleCheckMinDistance = 50,
  tripleThresholdHeight = 200,
  tripleThresholdDistance = 250,
  threshCutImage = 500,
  OffsetDistanceForEnvelopes = 10,
  maxEnvelopeROC = 35,
  maxNoise = 250,
  envelopeStartEndThreshold = 300,
  intersetionRemoveAmount = 1000,
  CreateTraceThreshold = 5,
  MARange = 6,
  region = 2,
  loopNumber = 4,
  spikeThreshold = 50,
  k = 40,
  gapLengthCutoff = 20
)

Arguments

imageName

The name of the file

fileLoc

Path from ~/ to the dir where the file is

pathToWorkingDir

Path of where the plots should be saved to

improvement

TRUE or FALSE depending on if you are adding any of the improvement features, causes TISI to ignore some check

HDVcheck

For Magneto project only, use FALSE otherwise

plotPNG

TRUE or FALSE if you want plots saved or just data returned

saveData

TRUE or FALSE if wanting a .RDS file saved to dir along with the image if plotPNG is TRUE

improveTopBottomCuts

Vector of length two consisting of the two points as heights that will become the new top and bottom cuts respectively

improveTTopEnvelope

data.frame of col x and col y representing points for top of the top envelope pair doesn't need to be a point for each column in original picture, will fill in the blanks

improveBTopEnvelope

data.frame of col x and col y representing points for Bottom of the top envelope pair doesn't need to be a point for each column in original picture, will fill in the blanks

improveTBottomEnvelope

data.frame of col x and col y representing points for top of the bottom envelope pair doesn't need to be a point for each column in original picture, will fill in the blanks

improveBBottomEnvelope

data.frame of col x and col y representing points for bottom of the bottom envelope pair doesn't need to be a point for each column in original picture, will fill in the blanks

improveTopEnvelopeStartEnd

Vector of length 2, start and end point respectively

improveBottomEnvelopeStartEnd

Vector of length 2, start and end point respectively

trimAmountTop

Number of pixels removed from top of image (usually for common flares)

trimAmountBottom

Number of pixels removed from bottom of image

trimAmountLeft

Percentage of the image that is guaranteed to not have any trace in it(mostly used to remove over exposure from the scanning process)

trimAmountRight

Percentage of the image that is guaranteed to not have any trace in it(mostly used to remove over exposure from the scanning process)

beta0

The intercept of a logistic regression default is for magnetograms Logistic regression on the decision if an image can be considered to be bright based off of a user deciding bright or non bright on a large set of images

beta1

The slope of the logistic regression default is for magnetograms

cutoffProbability

The probability cut off for the decision of an imageMatrix being bright

NADefault

The default value to replace NA's found in the matrix

FilterBright

Vector specifying the dimensions of the kernel, which will be used to perform either delation or erosion, such as c(13,13)

FilterNonBright

Vector specifying the dimensions of the kernel, which will be used to perform either delation or erosion, such as c(8,8)

methodBright

For bright images, choose 'delation'(adds to image, making brights brighter) or 'erosion' (subtracts from image, making brights darker) to occur during processing

methodNonBright

For non bright images, choose 'delation'(adds to image, making brights brighter) or 'erosion' (subtracts from image, making brights darker) to occur during processing

thresholdBright

should be between 0 and 1 for black and white pixels, where the Default = 0.8 anything over the threshold will be 1(white) and anything under will be turned to 0(black)

thresholdNonBright

should be between 0 and 1 for black and white pixels, where the Default = 0.5 anything over the threshold will be 1(white) and anything under will be turned to 0(black)

peakPercFromEdge

Used in find_peaks if you know there won't be any relevant data in that region for finding rowSum peaks. This percentage is removed from consideration in find_peaks in a region (look at rowSums of the matrix to see the peaks for this parameter)

peakPercentFromEdgeLeftSide

Passed into find peaks, if not specified (NULL), uses peakPercFromEdge for both left and right sides. If specified, peakPercFromEdge is defaulted to just the right side of the plot (look at rowSums of the matrix to see the peaks for this parameter)

cutPercentage

Usually the min of either trimAmountLeft or trimAmountRight

shortestAllowedSeqOfZeros

Smallest gap allowed between the lower trace and the timing marks, before the trace is considered to intersect with the timing marks

tripleCheckMinDistance

Minimum distance allowed between found peaks from rowSums(). Ensures that the user has max one point per peak (only used for magneto, make large if not needed)

tripleThresholdHeight

How different the heights can be for three peaks to be considered to be a triple set of peaks (only used for magneto, make 0 if not needed)

tripleThresholdDistance

How far apart the peaks can be for the them to be considered to be a set of triples (only used for magneto, make large if not needed)

threshCutImage

Used in triple_check as a second way to check for triples, takes the cut image(no timing or writing on the image) it then finds peaks and checks for 3 peaks(a triple) Same definition as the tripleThresholdDistance but different value needed because different scale

OffsetDistanceForEnvelopes

How far off of the trace you would like the envelope to be used as a safety net to catch any parts of the trace that might not be detected

maxEnvelopeROC

The max difference (rate of change) between any two points of the trace envelope before the outlier point will be removed and considered to be noise, these are usually seen as jumps in the envelopes

maxNoise

The max amount of points created off of the trace before the envelope can be considered to be not filling in a gap but being off of the trace entirely, will correct after this number

envelopeStartEndThreshold

The default vertical start and end location for the trace lines, if they aren't found automatically

intersetionRemoveAmount

The amount ignored from both the right and left sides of the image where possible trace lines could intersect because of noise This is to ensure that false intersections aren't found between the two traces

CreateTraceThreshold

During the final digitization lines of traces, any difference found higher then the CreateTraceThreshold between any two points will be smoothed with a MA

MARange

The amount of points in each direction that the moving average will look at to calculate the MA on (added to the region value for the whole MARange)

region

The number of points inside the MA that will be corrected to the MA value

loopNumber

The amount of times the MA Smoothing will happen, to guarantee elimination of other peaks that could be created from the MA

spikeThreshold

The difference in height between two pixels in the final digitization lines checks for abnormal spikes in the tracing algorithm, could be due to a jump from one trace to another (anything above the threshold will be sent to warning)

k

See rollMean() in zoo package for details

gapLengthCutoff

How large the gap between the writing at the start of the trace (seen in Fig 7) and the actual start of the trace must be in order to consider that point the new start, if gap is less then cutoff, will keep looking until it gets to the thresh value. If no writing on start of traces, this can be set to 0.

Details

Beta 0 and Beta1 are required for the brightness, changes the method for the image processing, if an image is bright, the parameters change to try and remove the over exposure so the envelopes can be more accurate around a trace. These can be found using a logistic regression with the predictor of the proportion of pixels above 0.8 scaled by the total number of pixels. The user imput the response variable, a decision of 0(not bright) and 1(bright) for a large number of images, to "train" the algorithm what to decide.


Bott-binc/magnetoPackage2020 documentation built on Oct. 12, 2024, 7:49 p.m.