retina
Class OIDAnalysis

java.lang.Object
  |
  +--retina.OIDAnalysis

public class OIDAnalysis
extends java.lang.Object

Optical Imaging frame sequence analysis. Many methods to aggregate and analyze the frames in epochs according to different methods. (c) 2003-2004 Michael Abramoff. All rights reserved.


Field Summary
static int BLOCK
           
static int CONTRAST
           
static int DIVISION
           
static int SEPARATE
           
static int SUBTRACT
           
 
Constructor Summary
OIDAnalysis()
           
 
Method Summary
static float[][][] alignmentTimecourseAnalysis(float[][] regEstimates, int nrUnique, int length)
          Do timecourse analysis of all alignment (motion) parameters of each frame.
protected static double[] analyzeBags(float[] aggrPixelsStim, float[] aggrPixelsControl, int method)
          Analyze two arrays of pixel values by calculating their ratio and the standard error of the ratio.
protected static double[] averageCalculate(float[][] a, int j, int nrConditionsPerUniqueCondition, int length, int start, int end, float[] mask)
          Calculate the average frame for a number of frames based on a mask for all repeats.
protected static void bagPixels(float[][] a, int j, int nrRepeats, int length, float[] mask, int start, int n, float[] aggrPixelsStim, float[] aggrPixelsNonStim)
          Collect all pixels in into arrays aggrPixelsStim respectively aggrPixelsNonStim using a mask, where pixels with mask = 1 go into aggrPixelsStim and pixels with mask = -1 go into aggrPixelsNonStim, pixels with mask = 0 are ignored.
protected static void bagPixels(float[][] a, int j, int nrRepeats, int length, int start, int n, float[] aggrPixels)
          Collect all pixels into an array aggrPixels Only pixels in the frames belonging to unique condition j are collected.
static float[][] baselineAnalysis(float[][] a, int nrUnique, int length, int baselineCondition, int start, int end)
          Do baseline frame analysis on each frame in a separately.
static double[] blockAnalysis(float[][][] r, int start, java.lang.String name, java.lang.String maskname, java.lang.String[] conds, int foveax, int foveay)
          Analyze r blockwise.
protected static float[] computeConditionDeltas(BIJpca pca, int conditionNumber, int nrUnique, float[] waveform)
          Compute deltas, the difference of the means of the time-coordinates an's over the conditions stimulus = ON and stimulus = OFF.
protected static double[][] computeFramesSummation(float[][] a, int width, int nrUnique, int length, int start, int end, int binning)
           
protected static float[] computeTruncationContributions(BIJpca pca, float[] waveform, int j, int width, int nrUnique, int length, int start, int end, int nrConditionsPerUniqueCondition, double confidenceLimit)
          Compute the truncation factors for pca and the confidenceLimit for a single condition.
static float[][] conditionAnalysis(float[][][] r, float[][] error, int start)
          Condition analysis of timecourse data.
static float[][] diffPairwise(float[][] a, int length, int start, int end)
          Perform pairwise differencing on all conditions.
static void firstframeAnalysis(float[][] ff, float[][] ffavg, float[][] a, int width, int nrUnique, int length, int baselineStart, int baselineEnd)
          Do first frame analysis on each stimulus frame (averaged for each condition) in a separately.
static void firstframeAnalysisAllFrames(float[][] ff, float[][] a, int width, int nrUnique, int length, int baselineStart, int baselineEnd, int start, int end, int type)
          Do first frame analysis on all frames (averaged for each condition) in a separately, including the frames which were before the stimulus.
static float[][] firstframeAnalysisDynamics(float[][] a, int j, int nrUnique, int n, int length, int baselines, int start, int end)
          Make a dynamic movie of the first frame method.
static float[][] firstframeConditionAnalysis(float[][] a, int width, int length, int baselineStart, int baselineEnd)
          Do first frame analysis on each condition in a separately.
static void firstframeDivisionCompact(float[][] a, int width, int nrUnique, int length, int baselineStart, int baselineEnd, int start)
          Do first frame analysis on each stimulus frame (averaged for each condition) very compactly and in place.
static void firstframeDivisionDouble(float[][] ff, float[][] ffavg, float[][] a, int width, int nrUnique, int length, int baselineStart, int baselineEnd, int firstframeStart, int firstframeEnd)
          Do first frame analysis on each stimulus frame (averaged for each condition) in a separately using double.
static float[] fitAnalysis(float[][][] r, int length, double framems, java.lang.String name, int start)
          Determine the fit of the curve in
protected static float[][] fullfieldAnalysis(float[][] a, float[][] sem, int width, int nrUnique, int length, int start)
          Analysis without masks.
protected static float[] getSignalWave(int j, int nrUnique, int length, int start, int end, int nrConditionsPerUniqueCondition)
          Calculate the ideal waveform of the signal, which is -1 if the stimulus for condition j is off and +1 if it is on.
static float[][][] maskTimecourseAnalysis(float[][] a, float[][][][] sortedregs, float[][] regs, float[][] sem, int width, int nrUnique, int length, float[][] masks, int useMask)
          Timecourse analysis using masks over all frames.
protected static float noiseAnalysis(float[][] a, int nrUnique, int length, float[][] masks, int useMask)
          Analysis of noise in a without masks.
protected static void putAveragesAtEnd(float[][] a, int n, int length)
          Compute the average of each group of n vectors (there are n groups) of length length in a into the length+1 vector in a.
static void saveTimecourse(java.lang.String name, java.lang.String directory, float[][] a, int length, int start, int end)
          Save the timecourse for a as a TIFF file.
protected static float[] spawnWaveform(float[] waveform, int cond, int nrUnique, int length, int nrConditionsPerUniqueCondition)
          Waveform describes the form of the signal for a single condition, and should be 0 where the truncation should be indifferent.
static double[][][] spectralAnalysis(float[][][] r, int length, double framems, java.lang.String name)
          Spectral analysis of timecourse data, Data is organized as r[j][k][i] where j is the condition, k is the frame number relative to the start of the cycle, and i is the repeat number.
protected static float[][][] timecourseAnalysis(int method, float[][] a, float[][][][] sortedregs, float[][] regs, float[][] sem, int width, int nrUnique, int length, float[][] masks, int useMask, int start)
          Timecourse analysis using masks over all frames.
static float[][] timecourseBeatAnalysis(float[][] a, float[][] sem, int width, int nrUnique, int length, int baselineStart, int baselineEnd, float[][] masks)
          Do timecourse analysis of the area that is 1 in masks[0] for each condition relative to a baseline area that is 1 in masks[0], averaged between baselineStart and baselineEnd.
protected static double trianglewave(double t, double start, double length, double min, double max)
          Double triangle wave.
protected static double trianglewave(int frame, int start, int length, double frameduration, double min, double max)
          Double triangle wave in terms of frames.
static float[][] truncatedDifferenceAnalysis(BIJpca pca, int width, int nrUnique, int length, int start, int end, float[] waveform, int nrConditionsPerUniqueCondition, double confidenceLimit)
          Do truncated difference analysis (averaged for each condition) in a separately.
static float[][] truncatedSequenceAnalysis(BIJpca pca, int width, int nrUnique, int length, int start, int end, float[] waveform, int nrConditionsPerUniqueCondition, double confidenceLimit)
          Performs truncated sequence analysis, i.e.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUBTRACT

public static final int SUBTRACT

DIVISION

public static final int DIVISION

CONTRAST

public static final int CONTRAST

SEPARATE

public static final int SEPARATE

BLOCK

public static final int BLOCK
Constructor Detail

OIDAnalysis

public OIDAnalysis()
Method Detail

diffPairwise

public static float[][] diffPairwise(float[][] a,
                                     int length,
                                     int start,
                                     int end)
Perform pairwise differencing on all conditions.
Parameters:
a - the frames.
length - the number of frames per conditions.
start - the start frame of the stimulus
end - the last frame for the stimulus
Returns:
a float[][] containg the pairwise subtraction of each condition.

truncatedDifferenceAnalysis

public static float[][] truncatedDifferenceAnalysis(BIJpca pca,
                                                    int width,
                                                    int nrUnique,
                                                    int length,
                                                    int start,
                                                    int end,
                                                    float[] waveform,
                                                    int nrConditionsPerUniqueCondition,
                                                    double confidenceLimit)
Do truncated difference analysis (averaged for each condition) in a separately. Return a float[][] with the truncated differences for all conditions.
Parameters:
BIJpca - pca the pca analysis of all frames, which were sorted by condition.
nrUnique - the number of unique conditions.
length - number of frames for single condition.
start - first frame during which stimulus was on in each condition.
end - last frame during which stimulus was on in each condition.
nrConditionsPerUniqueCondition - how many repeats for each unique condition
waveform - a float[] that contains the expected signal waveform, if null, a square waveform is synthesized from stimulus start and end time.
confidenceLimit - the confidence value up to which eigenimages will be included in the truncated difference.
Returns:
a float[][] with trunctated difference for each condition.

truncatedSequenceAnalysis

public static float[][] truncatedSequenceAnalysis(BIJpca pca,
                                                  int width,
                                                  int nrUnique,
                                                  int length,
                                                  int start,
                                                  int end,
                                                  float[] waveform,
                                                  int nrConditionsPerUniqueCondition,
                                                  double confidenceLimit)
Performs truncated sequence analysis, i.e. make a linear combinations (for all t) of the subset of all eigenimages, where only those eigenimages are included that fit the waveform desired. Return a float[][] with the truncated differences for all t and all conditions.
Parameters:
BIJpca - pca the pca analysis of all frames, which were sorted by condition.
nrUnique - the number of unique conditions.
length - number of frames for single condition.
start - first frame during which stimulus was on in each condition.
end - last frame during which stimulus was on in each condition.
nrConditionsPerUniqueCondition - how many repeats for each unique condition
confidenceLimit - the confidence value up to which eigenimages will be included in the truncated difference.
Returns:
a float[][] with trunctated difference for each condition. Organized as follows:
 cond = 0: frame t=0, frame t=1 ...., frame t= end-start+1, average of all
 cond = 1: frame t=0, frame t=1 ...., frame t= end-start+1, average of all
 ...
 cond = nrUnique-1: frame t=0, frame t=1 ...., frame t= end-start+1, average of all
 

computeTruncationContributions

protected static float[] computeTruncationContributions(BIJpca pca,
                                                        float[] waveform,
                                                        int j,
                                                        int width,
                                                        int nrUnique,
                                                        int length,
                                                        int start,
                                                        int end,
                                                        int nrConditionsPerUniqueCondition,
                                                        double confidenceLimit)
Compute the truncation factors for pca and the confidenceLimit for a single condition. Computes the contributions of each of the eigenimages, given that the confidence limit for the eigenimage to be included is >= confidenceLimit.
Parameters:
BIJpca - pca the pca analysis of all frames, which were sorted by condition.
j - the condition.
nrUnique - the number of unique conditions.
length - number of frames for single condition.
start - first frame during which stimulus was on in each condition.
end - last frame during which stimulus was on in each condition.
nrConditionsPerUniqueCondition - how many repeats for each unique condition
confidenceLimit - the confidence value up to which eigenimages will be included in the truncated difference.
Returns:
a float[] with the delta factor for each t.

spawnWaveform

protected static float[] spawnWaveform(float[] waveform,
                                       int cond,
                                       int nrUnique,
                                       int length,
                                       int nrConditionsPerUniqueCondition)
Waveform describes the form of the signal for a single condition, and should be 0 where the truncation should be indifferent. Place the waveform in the full waveform for all of the conditions, so that it is only nonzero in condition j.
Parameters:
waveform - a float[] that contains the expected signal waveform, if null, a square waveform is synthesized from stimulus start and end time.
cond - the unique condition number (there can be multiple non-unique for a single cond, see nrConditionsPerUniqueCondition)
nrUnique - the number of unique conditions.
length - number of frames for single condition.
nrConditionsPerUniqueCondition - how many repeats for each unique condition
waveform - a float[] that contains the expected signal waveform, if null, a square waveform is synthesized from stimulus start and end time.
confidenceLimit - the confidence value up to which eigenimages will be included in the truncated difference.
Returns:
a float[][] with trunctated difference for each condition.

getSignalWave

protected static float[] getSignalWave(int j,
                                       int nrUnique,
                                       int length,
                                       int start,
                                       int end,
                                       int nrConditionsPerUniqueCondition)
Calculate the ideal waveform of the signal, which is -1 if the stimulus for condition j is off and +1 if it is on. So it is an array filled with -1s, except where the stimulus for condition j was on, where the entries are +1.
Parameters:
j - the condition to compute the waveform for.
nrUnique - the number of unique conditions in the waveform
length - the number of frames for each condition
start - start of the stimulus
end - last frame with stimulus on

computeConditionDeltas

protected static float[] computeConditionDeltas(BIJpca pca,
                                                int conditionNumber,
                                                int nrUnique,
                                                float[] waveform)
Compute deltas, the difference of the means of the time-coordinates an's over the conditions stimulus = ON and stimulus = OFF. Deltan = Avg(an stim) - Avg(an non-stim)
Parameters:
pca - the PCA object
nrUnique - the number of unique conditions.
conditionNumber - the condition: 0 <= conditionNumber < nrUnique.
waveform - contains the waveform you want to compute the averages for. waveform should contain value > 0 wherever the stimulus is 'ON', and a value < 0 where the stimulus is 'OFF'.
Returns:
a vector containing the difference of the averaged coordinates for stimulus on and off for condition nrUnique.

firstframeAnalysis

public static void firstframeAnalysis(float[][] ff,
                                      float[][] ffavg,
                                      float[][] a,
                                      int width,
                                      int nrUnique,
                                      int length,
                                      int baselineStart,
                                      int baselineEnd)
Do first frame analysis on each stimulus frame (averaged for each condition) in a separately. First frame analysis means subtracting/dividing by a baseline average (of frames baselineStart - baselineEnd) from each frame. a must be sorted by condition. Because ff and ffavg can be pre existent, you can also add to an existing summation over multiple a. Size of ff should be new float[nrUnique * nrstimframes][a[0].length] Size of ffavg should be new float[nrUnique][a[0].length] Rounding errors avoided by summation over all conditions, then subtracting the firstframe total over all conditions, and only then computing average. Shoham and Grinvald, 2001
Parameters:
ff - the matrix to which, on exit, will be added the first frame analysis for each unique condition and each stim frame in a.
ffavg - the matrix to which, on exit, will be added the average of ff over all stim frames.
a - the array of frames.
nrUnique - the number of unique conditions.
baselineStart, - index of first frame that counts as baseline
baselineEnd, - index of last frame that counts as baseline.
end - end of stimulus. So the organization is:
 ff:
     cond = 0: frame t=start, frame t=start+1 ..., frame t= end-start+1
     cond = 1: frame t=start, frame t=start+1 ..., frame t= end-start+1
       ...
     cond = nrUnique-1: t=start, frame t=start+1 ..., frame t= end-start+1
 ffavg...
     cond = 0: average ff[0] ... ff[end-start+1]
     cond = 1: average ff[0] ... ff[end-start+1]
       ...
     cond = nrUnique-1: average ff[0] ... ff[end-start+1]
 

firstframeConditionAnalysis

public static float[][] firstframeConditionAnalysis(float[][] a,
                                                    int width,
                                                    int length,
                                                    int baselineStart,
                                                    int baselineEnd)
Do first frame analysis on each condition in a separately. First frame analysis means subtracting a baseline average (of frames baselineStart - baselineEnd) from each frame. Because ff can be pre existent, you can also add to an existing summation over multiple a. Size of ff should be new float[a.length][a[0].length]
Parameters:
ff - the matrix to which, on exit, will be added the first frame analysis for each condition.
a - the array of frames.
width - the width of each image in a.
nrUnique - the number of unique conditions in.
length - the length of each condition.
baselineStart, - index of first frame that counts as baseline
baselineEnd, - index of last frame that counts as baseline.

firstframeAnalysisAllFrames

public static void firstframeAnalysisAllFrames(float[][] ff,
                                               float[][] a,
                                               int width,
                                               int nrUnique,
                                               int length,
                                               int baselineStart,
                                               int baselineEnd,
                                               int start,
                                               int end,
                                               int type)
Do first frame analysis on all frames (averaged for each condition) in a separately, including the frames which were before the stimulus. This way you can see what the status was before the stimulus came on. There is no extra average frame. Rounding errors avoided by summation over all conditions, then subtracting the firstframe total over all conditions, and only then computing average. Shoham and Grinvald, 2001
Parameters:
ff - the matrix to which, on exit, will be added the first frame analysis for each unique condition and each stim frame in a.
ffavg - the matrix to which, on exit, will be added the average of ff over all stim frames.
a - the array of frames.
nrUnique - the number of unique conditions.
baselineStart, - index of first frame that counts as baseline
baselineEnd, - index of last frame that counts as baseline.
start - start of stimulus in each epoch.
end - end of stimulus. So the organization is:
 ff:
     cond = 0: frame t=0, frame t=1 ...., frame t=length-1
     cond = 1: frame t=0, frame t=1 ...., frame t=length-1
       ...
     cond = nrUnique-1: frame t=0, frame t=1 ...., frame t=length-1
 

computeFramesSummation

protected static double[][] computeFramesSummation(float[][] a,
                                                   int width,
                                                   int nrUnique,
                                                   int length,
                                                   int start,
                                                   int end,
                                                   int binning)

timecourseBeatAnalysis

public static float[][] timecourseBeatAnalysis(float[][] a,
                                               float[][] sem,
                                               int width,
                                               int nrUnique,
                                               int length,
                                               int baselineStart,
                                               int baselineEnd,
                                               float[][] masks)
Do timecourse analysis of the area that is 1 in masks[0] for each condition relative to a baseline area that is 1 in masks[0], averaged between baselineStart and baselineEnd. In other words, calculate the average for each pixel that has 1 in masks[0] and divide each pixel that has 1 in masks[0] by that baseline average. Assumes a repeat of multiple repeats of a condition, so does correction with linear approximation of the slow change in the timecourse. I.e. assumes there is no difference between the begin of a condition and the end of the previous one.
Parameters:
a - the array of frames.
sem - a float[][] that can be null. If not null should contain space for standard error of the mean for each unique condition and time.
nrUnique - the number of unique conditions.
length - number of frames for each condition
masks - the masks that contain the stimulated and non-stimulated area for each condition. Only masks[0] is used!
Returns:
a float[nrUnique][length] with the timecourse for each unique condition.

averageCalculate

protected static double[] averageCalculate(float[][] a,
                                           int j,
                                           int nrConditionsPerUniqueCondition,
                                           int length,
                                           int start,
                                           int end,
                                           float[] mask)
Calculate the average frame for a number of frames based on a mask for all repeats. Return the average frame as a double[][] for more precision.

alignmentTimecourseAnalysis

public static float[][][] alignmentTimecourseAnalysis(float[][] regEstimates,
                                                      int nrUnique,
                                                      int length)
Do timecourse analysis of all alignment (motion) parameters of each frame. Computes the average x, y, and rotation motion for each frame per condition.
Parameters:
regEstimates - the array with the registration estimates for all frames, for each frame, multiple parameters (x, y, rot...).
nrUnique - the number of unique conditions.
length - number of frames for each condition
Returns:
a float[nrUnique][regEstimates[0].length][length] with the timecourse of the alignment for each condition and each direction.

maskTimecourseAnalysis

public static float[][][] maskTimecourseAnalysis(float[][] a,
                                                 float[][][][] sortedregs,
                                                 float[][] regs,
                                                 float[][] sem,
                                                 int width,
                                                 int nrUnique,
                                                 int length,
                                                 float[][] masks,
                                                 int useMask)
Timecourse analysis using masks over all frames. The masks indicate which parts of the retina have been stimulated (1) and which not (-1), and which pixels should not be used (0). There is a mask for each unique condition. Determine the pixel CCD count totals for the stimulated and the non-stimulated areas over all repeats, and average over number of pixels. Divide stimulated / non-stimulated, and that is the value for the timecourse for that frame in that condition, averaged over all repeats.
Parameters:
a - the array of frames.
sem - an array that can hold the standard error of the mean if not null.
width - the width in pixels of each frame.
nrUnique - the number of unique conditions.
length - number of frames for each condition
masks - the masks for each condition. These are the same size as the frames in a.
useMask, - if >=0, use masks[singleCondition], otherwise use each mask.
Returns:
a float[][] with the timecourse for each condition.

timecourseAnalysis

protected static float[][][] timecourseAnalysis(int method,
                                                float[][] a,
                                                float[][][][] sortedregs,
                                                float[][] regs,
                                                float[][] sem,
                                                int width,
                                                int nrUnique,
                                                int length,
                                                float[][] masks,
                                                int useMask,
                                                int start)
Timecourse analysis using masks over all frames. The masks indicate which parts of the retina have been stimulated (1) and which not (-1), and which pixels should not be used (0). There is a mask for each unique condition. Determine the pixel CCD count totals for the stimulated and the non-stimulated areas over all repeats, and average over number of pixels. Divide stimulated / non-stimulated, and that is the value for the timecourse for that frame in that condition, averaged over all repeats.
Parameters:
a - the array of frames.
sortedregs, - a float[condition][frame][cycle][] for regs. if regs is not null, will contain the sorted parameters in regs.
regs - a float[][] array of extra parameters for each frame in a, for example registration parameters.
sem - an array that can hold the standard error of the mean if not null.
width - the width in pixels of each frame.
nrUnique - the number of unique conditions.
length - number of frames for each condition
masks - the masks for each condition. These are the same size as the frames in a.
useMask, - if >=0, use masks[singleCondition], otherwise use each mask.
Returns:
a float[condition][frame][cycle] with the timecourse for each condition, cycle and frame respectively.

conditionAnalysis

public static float[][] conditionAnalysis(float[][][] r,
                                          float[][] error,
                                          int start)
Condition analysis of timecourse data. Average the timecourse of r for all repetitions for each frame, and normalize to the maximum r. Compute the deviation from the average.

blockAnalysis

public static double[] blockAnalysis(float[][][] r,
                                     int start,
                                     java.lang.String name,
                                     java.lang.String maskname,
                                     java.lang.String[] conds,
                                     int foveax,
                                     int foveay)
Analyze r blockwise. Use a block of r values before the stimulus goes on and one after the stimulus goes on. Compute the ratio between the two, that is the change in intensity due to the stimulus, and the p-value.

spectralAnalysis

public static double[][][] spectralAnalysis(float[][][] r,
                                            int length,
                                            double framems,
                                            java.lang.String name)
Spectral analysis of timecourse data, Data is organized as r[j][k][i] where j is the condition, k is the frame number relative to the start of the cycle, and i is the repeat number. Returns the Power Spectral Density of r that are close to the expected frequency of which the start is startfreq and the end is endfreq. These frequencies are not real frequencies, but in terms of frames, i.e. freq=18 means the psd for 18 frames per cycle.
Parameters:
r - the ratios for each condition, frame and repeat.
length - the length of each cycle in frames.
ms - the length of each frame in ms.
Returns:
a float[2][] with the psd in [1] and the 'frequency' in [0].

fitAnalysis

public static float[] fitAnalysis(float[][][] r,
                                  int length,
                                  double framems,
                                  java.lang.String name,
                                  int start)
Determine the fit of the curve in

fullfieldAnalysis

protected static float[][] fullfieldAnalysis(float[][] a,
                                             float[][] sem,
                                             int width,
                                             int nrUnique,
                                             int length,
                                             int start)
Analysis without masks. Computes the ratio of the average of a group of prestimulus frames and a group of stimulus frames and their standard errors. Comparable to timecourseAnalysis for BLOCK with the masks 1 everywhere. The masks indicate which parts of the retina have been stimulated (1) and which not (-1), and which pixels should not be used (0). There is a mask for each unique condition. Determine the pixel CCD count totals for the stimulated and the non-stimulated areas over all repeats, and average over number of pixels. Divide stimulated / non-stimulated, and that is the value for the timecourse for that frame in that condition, averaged over all repeats.
Parameters:
a - the array of frames.
sem - an array that can hold the standard error of the mean if not null.
width - the width in pixels of each frame.
nrUnique - the number of unique conditions.
length - number of frames for each condition
Returns:
a float[][] with the timecourse for each condition.

noiseAnalysis

protected static float noiseAnalysis(float[][] a,
                                     int nrUnique,
                                     int length,
                                     float[][] masks,
                                     int useMask)
Analysis of noise in a without masks. Compute the standard deviation of all pixels in all frames in a. This is a determinant of the total variability (noise) in a.
Parameters:
a - the array of frames.
sem - an array that can hold the standard error of the mean if not null.
width - the width in pixels of each frame.
nrUnique - the number of unique conditions.
length - number of frames for each condition
Returns:
a float[][] with the timecourse for each condition.

bagPixels

protected static void bagPixels(float[][] a,
                                int j,
                                int nrRepeats,
                                int length,
                                float[] mask,
                                int start,
                                int n,
                                float[] aggrPixelsStim,
                                float[] aggrPixelsNonStim)
Collect all pixels in into arrays aggrPixelsStim respectively aggrPixelsNonStim using a mask, where pixels with mask = 1 go into aggrPixelsStim and pixels with mask = -1 go into aggrPixelsNonStim, pixels with mask = 0 are ignored. Only pixels in the frames belonging to unique condition j are collected. Each conditions has length frames. Pixels are collected from all frames start..start+n.
Parameters:
a - the raw frames
the - number of the current condition.
nrRepeats - the number of times j is repeated in a.
length - the length of an epoch in frames.
mask - a float[] with for each pixel in a indicated 1,0 or -1.
start - the first frame when the stimulus is on.
aggrPixelsStim, - aggrPixelsNonStim the float[] whicha re bags for all pixel values within mask.

bagPixels

protected static void bagPixels(float[][] a,
                                int j,
                                int nrRepeats,
                                int length,
                                int start,
                                int n,
                                float[] aggrPixels)
Collect all pixels into an array aggrPixels Only pixels in the frames belonging to unique condition j are collected. Each conditions has length frames. Pixels are collected from all frames start..start+n.
Parameters:
a - the raw frames
the - number of the current condition.
nrRepeats - the number of times j is repeated in a.
length - the length of an epoch in frames.
mask - a float[] with for each pixel in a indicated 1,0 or -1.
start - the first frame when the stimulus is on.

analyzeBags

protected static double[] analyzeBags(float[] aggrPixelsStim,
                                      float[] aggrPixelsControl,
                                      int method)
Analyze two arrays of pixel values by calculating their ratio and the standard error of the ratio.
Returns:
a double array with the ratio in [0] and the standard error of the mean in [1].

baselineAnalysis

public static float[][] baselineAnalysis(float[][] a,
                                         int nrUnique,
                                         int length,
                                         int baselineCondition,
                                         int start,
                                         int end)
Do baseline frame analysis on each frame in a separately. This means subtracting the average of all stimulus frames in the baseline condition from each stimulus frame in each condition, and then averaging over all non-unique condition frames for each condition. Extra last frame for each condition is average of previous ones. Shoham and Grinvald, 2001
Parameters:
a - the array of frames.
nrUniqueConditions - the number of unique conditions.
baselineCondition - the number of the baseline condition among all unique conditions.
start - start of stimulus in each epoch.
end - end of stimulus.
Returns:
a float[][] with the analysis for each stimulus frame, plus the average as last. Will contain end-start+2 columns. So the organization is:
 cond = 0: frame t=0, frame t=1 ...., frame t= end-start+1, average of all
 cond = 1: frame t=0, frame t=1 ...., frame t= end-start+1, average of all
 ...
 cond = nrUnique-1: frame t=0, frame t=1 ...., frame t= end-start+1, average of all
 

trianglewave

protected static double trianglewave(int frame,
                                     int start,
                                     int length,
                                     double frameduration,
                                     double min,
                                     double max)
Double triangle wave in terms of frames. This function returns the value of the double triangle wave (an approximation of the expected response curve) at t. This function has its peak at start, a downslope after t until t+2 and then an upslope with a elevation that depends on length.
Parameters:
t - the value in s at which you want the y-value.
start - the time in s at which the stimulus goes on.
length - the duration in s of a cycle.
min - the minimum value
max - the maximum value

trianglewave

protected static double trianglewave(double t,
                                     double start,
                                     double length,
                                     double min,
                                     double max)
Double triangle wave. This function returns the value of the double triangle wave (an approximation of the expected response curve) at t. This function has its peak at start, a downslope after t until t+2 and then an upslope with a elevation that depends on length.
Parameters:
t - the value in s at which you want the y-value.
start - the time in s at which the stimulus goes on.
length - the duration in s of a cycle.
min - the minimum value
max - the maximum value

firstframeAnalysisDynamics

public static float[][] firstframeAnalysisDynamics(float[][] a,
                                                   int j,
                                                   int nrUnique,
                                                   int n,
                                                   int length,
                                                   int baselines,
                                                   int start,
                                                   int end)
Make a dynamic movie of the first frame method. For a chosen condition, subtract increasing amounts of the first frame average, so that ever less of the original image, and evre more of the first frame difference becomes visible.
Parameters:
a - the array of frames.
nrUniqueConditions - the number of unique conditions.
baselines - number of baseline frames from 1.
start - start of stimulus in each epoch.
end - end of stimulus.
Returns:
a float[][] with the firstframe dynamics movie for condition c.

putAveragesAtEnd

protected static void putAveragesAtEnd(float[][] a,
                                       int n,
                                       int length)
Compute the average of each group of n vectors (there are n groups) of length length in a into the length+1 vector in a. So the organization on exit is:
 group = 0: vector t=0, vector t=1 ...., vector t=length-1, average of 0-length-1 (t=length)
 group = 1: vector t=0, vector t=1 ...., vector t=length-1, average of 0-length-1 (t=length)
 ...
 group = n-1: vector t=0, vector t=1 ...., vector t=length-1, average of 0-length-1 (t=length)
 

firstframeDivisionDouble

public static void firstframeDivisionDouble(float[][] ff,
                                            float[][] ffavg,
                                            float[][] a,
                                            int width,
                                            int nrUnique,
                                            int length,
                                            int baselineStart,
                                            int baselineEnd,
                                            int firstframeStart,
                                            int firstframeEnd)
Do first frame analysis on each stimulus frame (averaged for each condition) in a separately using double. First frame analysis means dividing each frame by a baseline average (of frames baselineStart - baselineEnd). Because ff and ffavg can be pre existent, you can also add to an existing summation over multiple a. Size of ff should be new float[nrUnique * nrstimframes][a[0].length] Size of ffavg should be new float[nrUnique][a[0].length] Rounding errors avoided by summation over all conditions, then subtracting the firstframe total over all conditions, and only then computing average. Shoham and Grinvald, 2001
Parameters:
ff - the matrix to which, on exit, will be added the first frame analysis for each unique condition and each stim frame in a.
ffavg - the matrix to which, on exit, will be added the average of ff over all stim frames.
a - the array of frames, which has been sorted by condition.
nrUnique - the number of unique conditions.
baselineStart, - index of first frame that counts as baseline
baselineEnd, - index of last frame that counts as baseline. So the organization is:
 ff:
     cond = 0: frame t=start, frame t=start+1 ..., frame t= end-start+1
     cond = 1: frame t=start, frame t=start+1 ..., frame t= end-start+1
       ...
     cond = nrUnique-1: t=start, frame t=start+1 ..., frame t= end-start+1
 ffavg...
     cond = 0: average ff[0] ... ff[end-start+1]
     cond = 1: average ff[0] ... ff[end-start+1]
       ...
     cond = nrUnique-1: average ff[0] ... ff[end-start+1]
 

firstframeDivisionCompact

public static void firstframeDivisionCompact(float[][] a,
                                             int width,
                                             int nrUnique,
                                             int length,
                                             int baselineStart,
                                             int baselineEnd,
                                             int start)
Do first frame analysis on each stimulus frame (averaged for each condition) very compactly and in place. a is reused to store the result. First frame analysis means dividing each frame by a baseline average (of frames baselineStart - baselineEnd). Rounding errors avoided by summation over all conditions, then subtracting the firstframe total over all conditions, and only then computing average. Shoham and Grinvald, 2001
Parameters:
a - the array of frames, MODIFIED!.
nrUnique - the number of unique conditions.
baselineStart, - index of first frame that counts as baseline
baselineEnd, - index of last frame that counts as baseline.
end - end of stimulus.

saveTimecourse

public static void saveTimecourse(java.lang.String name,
                                  java.lang.String directory,
                                  float[][] a,
                                  int length,
                                  int start,
                                  int end)
Save the timecourse for a as a TIFF file.