public int getValueInSamples() { // retrieve the value as integer int val = value; int intSamples = 0; // check if the unit is set in seconds if (unit == Parameters.Units.Seconds) { // flagged as seconds // convert, check rounding double samples = SampleConversion.timeToSamplesAsDouble(val); // conversion result as double, no rounding before intSamples = (int)Math.Round(samples); if (samples != intSamples) { // message logger.Warn("Value for parameter '" + this.Name + "' (parameter set: '" + this.getParentSetName() + "') was retrieved in number of samples (" + val + "s * " + SampleConversion.sampleRate() + "Hz), but has been rounded from " + samples + " samples to " + intSamples + " samples"); } // convert and return return(intSamples); } else { // not flagged as seconds // assume the value is in samples and return the value return(val); } }
public static Bitmap ConvertSampleToBitmap(Sample sample) { SampleConversion convertor = new SampleConversion(); Bitmap bmp = null; convertor.ConvertToPicture(sample, ref bmp); return(bmp); }
protected Bitmap ConvertSampleToBitmap(Sample sample) { var convertor = new SampleConversion(); // Create a sample convertor. Bitmap bitmap = null; // TODO: the size doesn't matter convertor.ConvertToPicture(sample, ref bitmap); // TODO: return bitmap as a result return(bitmap); }
protected Bitmap ConvertSampleToBitmap(Sample Sample) { /* TODO: Create a Convertor which will return a bitmap no matter the size */ SampleConversion Convertor = new SampleConversion(); Bitmap bitmap = null; Convertor.ConvertToPicture(Sample, ref bitmap); return(bitmap); }
public void CreateBitmapFile(string pathToSaveBitmapTo) { if (_sample == null) { throw new NullReferenceException("_sample"); } var sampleConvertor = new SampleConversion(); Bitmap bitmap = null; sampleConvertor.ConvertToPicture(_sample, ref bitmap); bitmap.Save(pathToSaveBitmapTo); }
public int[] getValueInSamples() { // create an array of values (in samples) to return int[] retValues = new int[values.Length]; // loop through the array for (int i = 0; i < retValues.Length; i++) { // retrieve the value double val = values[i]; int intSamples = 0; // check if the unit is set in seconds if (units[i] == Parameters.Units.Seconds) { // flagged as seconds // convert, check rounding double samples = SampleConversion.timeToSamplesAsDouble(val); // conversion result as double, no rounding before intSamples = (int)Math.Round(samples); if (samples != intSamples) { // message logger.Warn("Value in parameter '" + this.Name + "' (parameter set: '" + this.getParentSetName() + "') was retrieved in number of samples (" + val + "s * " + SampleConversion.sampleRate() + "Hz), but has been rounded from " + samples + " sample(s) to " + intSamples + " sample(s)"); } } else { // not flagged as seconds // convert double to int, check rounding intSamples = (int)Math.Round(val); if (val != intSamples) { // message logger.Warn("Value in parameter '" + this.Name + "' (parameter set: '" + this.getParentSetName() + "') was retrieved in number of samples, but has been rounded from " + val + " sample(s) to " + intSamples + " samples"); } } retValues[i] = intSamples; } // return number of samples return(retValues); }
public int[][] getValueInSamples(int[] ignoreColumns) { // create an matrix of values (in samples) to return int[][] retValues = new int[values.Length][]; // loop through the columns for (int c = 0; c < units.Length; c++) { // check if column should be ignored, if so skip if (ignoreColumns != null && ignoreColumns.Length > 0) { bool ignoreColumn = false; for (int j = 0; j < ignoreColumns.Length; j++) { if (c == ignoreColumns[j]) { ignoreColumn = true; break; } } if (ignoreColumn) { continue; } } // create array of values (in samples) for this column retValues[c] = new int[values[c].Length]; // loop through the rows for (int r = 0; r < values[c].Length; r++) { // retrieve the value int val = values[c][r]; int intSamples = 0; // check if the unit is set in seconds if (units[c][r] == Parameters.Units.Seconds) { // flagged as seconds // convert, check rounding double samples = SampleConversion.timeToSamplesAsDouble(val); // conversion result as double, no rounding before intSamples = (int)Math.Round(samples); if (samples != intSamples) { // message logger.Warn("Value in parameter '" + this.Name + "' (parameter set: '" + this.getParentSetName() + "') was retrieved in number of samples (" + val + "s * " + SampleConversion.sampleRate() + "Hz), but has been rounded from " + samples + " samples to " + intSamples + " samples"); } // set the rounded value retValues[c][r] = intSamples; } else { // not flagged as seconds // assume the value is in samples and set the value retValues[c][r] = val; } } } // return number of samples return(retValues); }
// set state of task to given state private void setState(TaskStates state) { // check if there is a view to modify if (view == null) { return; } // transfer state taskState = state; // perform initial actions for new state switch (taskState) { case TaskStates.Start: // set text to display view.setText(startText); // feedback to user //logger.Debug("Participant is waiting for task to begin."); // log event participant is waiting Data.logEvent(2, "WaitPresented", CLASS_NAME); // initialize wait counter, determining how long this state will last waitCounter = firstSequenceWait; break; case TaskStates.Run: // show stimulus setStimulus(); break; case TaskStates.Wait: // set text to display view.setText(waitText); // feedback to user //logger.Debug("Participant is waiting for next stimulus."); // log event participant is waiting Data.logEvent(2, "WaitPresented", CLASS_NAME); break; case TaskStates.Pause: // set text to display view.setText("Task paused."); // feedback to user //logger.Debug("Task paused."); // log event task is paused Data.logEvent(2, "TaskPause", CLASS_NAME); break; case TaskStates.End: // set text to display view.setText(endText); // feedback to user //logger.Debug("Task finished."); // reset all relevant variables in case task is restarted currentStimulus = stimulusCounter = 0; currentRepetition = 1; stimulusRemainingTime = -1; // wait for two seconds waitCounter = SampleConversion.timeToSamples(2); break; default: // message logger.Error("Non-existing task state selected. Task will be stopped. Check code."); // stop the task stop(); break; } }