Beispiel #1
0
void currentAnalyzer::updateVentilationDuration( int duration )
{
    emit newDataPoint( _tempDataPoint, duration );
}
Beispiel #2
0
void Clamp::execute(void) {
	if (plotFI == true) spikestate = input(0);
	systime = count * dt; // current time, s

	if (cyclecount < repeat) { // as long as there are cycles remaining
		if (stepcount == 0 && randomize == true && random == false) { // shuffle amplitudes once at beginning of each cycle
			std::random_shuffle(arrstep, arrstep + nstep);
			random = true;
		}

		if (stepcount < nstep) { // as long as there are steps remaining in cycle
			if (systime >= delay && systime < (delay + width)) { // during command window, set output
				if (mode == STEP)	{
					output(0) = arrstep[stepcount];
				}
				else if (mode == RAMP) {
					if (systime >= delay && systime < (delay + width / 2)) {
						output(0) += arrrate[stepcount];
	  				}
					else {
						output(0) -= arrrate[stepcount];
					}
				}
				if ((spikestate == 1) && (plotFI == true)) countspikes();
			}

			else if (systime >= delay + width) { // after command window, shift delay, clean up
				delay = delay + delay0 + width;
				if (plotFI == true) {
					arrFIamp[static_cast<int> (cyclecount * nstep + stepcount)] = arrstep[stepcount] * 1e12; // in pA
					if (spikecount >= 2) { // at least 2 spikes (1 ISI) occurred
						arrFIHz[static_cast<int> (cyclecount * nstep + stepcount)] = 1 / ISI.mean();
						if (ISI.mean() != 0 && 1 / ISI.mean() > yrangemax) { // resize window
							yrangemax = 1 / ISI.mean();
							emit setFIRange(minamp * 1e12, maxamp * 1e12,
							yrangemin, yrangemax);
						}
						if (ISI.mean() != 0) {
							printf("%f%f\n", arrstep[stepcount] * 1e12, 1 / ISI.mean());
							emit newDataPoint(arrFIamp[cyclecount * nstep + stepcount], arrFIHz[cyclecount * nstep + stepcount]);
						}
					}
					else if (spikecount == 1) { // only 1 spike occurred
						arrFIHz[static_cast<int> (cyclecount * nstep + stepcount)] = GSL_NAN;
					}
					else { // no spikes occurred
						arrFIHz[static_cast<int> (cyclecount * nstep + stepcount)] = 0;
					}
					spikecount = 0;
					ISI.clear();
				}
				stepcount++;
				output(0) = 0;
			}
			else { // outside command window, set output to zero
			  output(0) = 0;
			}
		}
		if (stepcount == nstep) { // increment cycle count, reset flag for random shuffle
		 cyclecount++;
		 splot->nextSymbol();
		 stepcount = 0;
		 if (randomize == true) random = false;
		}
	}
	else { // all cycles are done
	} // end if cyclecount
	count++; // increment count to measure time
	return;
}