当前位置: 首页>>代码示例>>C++>>正文


C++ GenericSignal类代码示例

本文整理汇总了C++中GenericSignal的典型用法代码示例。如果您正苦于以下问题:C++ GenericSignal类的具体用法?C++ GenericSignal怎么用?C++ GenericSignal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GenericSignal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Process

// **************************************************************************
// Function:   Process
// Purpose:    This function is called within the data acquisition loop
//             it fills its output signal with values
//             and does not return until all data has been acquired.
// Parameters: References to input signal (ignored) and output signal.
// Returns:    N/A
// **************************************************************************
void NeuroSkyADC::Process( const GenericSignal&, GenericSignal& Output )
{
  // Clear out old data
  mDataBlock.clear();
  
  // Fill a Sample Block
  for( int i = 0; i < Output.Elements(); i++ )
  {    
    // Read Packets until new raw data comes in
    while( true )
    {
      TG_ReadPackets( mConnectionID, 1 );
      if( TG_GetValueStatus( mConnectionID, TG_DATA_RAW ) != 0 )
        break;
      Sleep( 1 );
    } 
    
    // Push the newest data into the data block
    mDataBlock.push_back( TG_GetValue( mConnectionID, TG_DATA_RAW ) );
  }
  
  // Fill the output with that data
  for( int sample = 0; sample < Output.Elements(); ++sample )
      Output( 0, sample ) = mDataBlock[ sample ];
}
开发者ID:ACrazyer,项目名称:NeuralSystemsBCI2000,代码行数:33,代码来源:NeuroSkyADC.cpp

示例2: switch

void
BCI2000OutputFormat::Write( ostream& os, const GenericSignal& inSignal, const StateVector& inStatevector )
{
  switch( mInputProperties.Type() )
  {
    case SignalType::int16:
    case SignalType::float32:
    case SignalType::int32:
      // Note that the order of Elements and Channels differs from the one in the
      // socket protocol.
      for( int j = 0; j < inSignal.Elements(); ++j )
      {
        for( int i = 0; i < inSignal.Channels(); ++i )
          inSignal.WriteValueBinary( os, i, j );
        os.write(
          reinterpret_cast<const char*>( inStatevector( min( j, inStatevector.Samples() - 1 ) ).Data() ),
          inStatevector.Length()
        );
      }
      break;

    default:
      bcierr << "Unsupported signal data type" << endl;
  }
}
开发者ID:ACrazyer,项目名称:NeuralSystemsBCI2000,代码行数:25,代码来源:BCI2000OutputFormat.cpp

示例3: Input

void
Normalizer::Process( const GenericSignal& Input, GenericSignal& Output )
{
  if( mDoAdapt )
  {
    for( size_t channel = 0; channel < mBufferConditions.size(); ++channel )
      for( size_t buffer = 0; buffer < mBufferConditions[ channel ].size(); ++buffer )
      {
        double label = mBufferConditions[ channel ][ buffer ].Evaluate( &Input );
        if( label != 0 )
          for( int sample = 0; sample < Input.Elements(); ++sample )
            mDataBuffers[ channel ][ buffer ].Put( Input( channel, sample ) );
      }
    if( mpUpdateTrigger != NULL )
    {
      bool currentTrigger = mpUpdateTrigger->Evaluate( &Input );
      if( currentTrigger && !mPreviousTrigger )
        Update();
      mPreviousTrigger = currentTrigger;
    }
    else
      Update();
  }

  for( int channel = 0; channel < Input.Channels(); ++channel )
    for( int sample = 0; sample < Input.Elements(); ++sample )
      Output( channel, sample )
        = ( Input( channel, sample ) - mOffsets[ channel ] ) * mGains[ channel ];
}
开发者ID:ACrazyer,项目名称:NeuralSystemsBCI2000,代码行数:29,代码来源:Normalizer.cpp

示例4: lock

void
SignalDisplay::AdaptTo( const GenericSignal& inSignal )
{
    // Any changes in the signal size that we must react to?
    bool reconfigure = false;
    if( inSignal.Elements() > mNumSamples )
    {
        OSMutex::Lock lock( mDataLock );
        SetNumSamples( inSignal.Elements() );
        reconfigure = true;
    }
    if( inSignal.Channels() != mData.Channels() )
    {
        OSMutex::Lock lock( mDataLock );
        int newNumDisplayGroups = ( inSignal.Channels() - mMarkerChannels - 1 ) / mChannelGroupSize + 1;
        if( mNumDisplayGroups == 0 )
            mNumDisplayGroups = min<int>( newNumDisplayGroups, cInitialMaxDisplayGroups );
        else if( newNumDisplayGroups < mNumDisplayGroups )
            mNumDisplayGroups = newNumDisplayGroups;
        reconfigure = true;
    }
    if( reconfigure )
    {
        OSMutex::Lock lock( mDataLock );
        mData = GenericSignal( inSignal.Channels(), mNumSamples );
        SetDisplayGroups( DisplayGroups() );
        SyncLabelWidth();
        mSampleCursor = 0;
        Invalidate();
    }
}
开发者ID:ACrazyer,项目名称:NeuralSystemsBCI2000,代码行数:31,代码来源:SignalDisplay.cpp

示例5: inSignal

////////////////////////////////////////////////////////////////////////////////
// MatlabEngine::DoubleMatrix definitions                                     //
////////////////////////////////////////////////////////////////////////////////
MatlabEngine::DoubleMatrix::DoubleMatrix( const GenericSignal& inSignal )
    : vector<vector<double> >( inSignal.Channels(), vector<double>( inSignal.Elements() ) )
{
    for( size_t channel = 0; channel < size(); ++channel )
        for( size_t sample = 0; sample < ( *this )[ channel ].size(); ++sample )
            ( *this )[ channel ][ sample ] = inSignal( channel, sample );
}
开发者ID:el-fran,项目名称:weka-bci2000,代码行数:10,代码来源:MatlabWrapper.cpp

示例6: lock

// The Process() function is called from the main thread in regular intervals.
void
BufferedADC::Process( const GenericSignal&,
                      GenericSignal& Output )
{
    this->OnProcess();
    AcquisitionBuffer& buffer = mpBuffers[mReadCursor];
    ++mReadCursor %= mSourceBufferSize;

    Lock lock( buffer );
    if( !IsAcquiring() )
    {
        bcierr_ << ( mError.empty() ? "Acquisition Error" : mError );
        if( State( "Running" ) )
            State( "Running" ) = 0;
        return;
    }

    if( buffer.Signal.Channels() == Output.Channels() )
        Output = buffer.Signal;
    else
    {
        const LabelIndex& labels = mAcquisitionProperties.ChannelLabels();
        for( int el = 0; el < Output.Elements(); ++el )
        {
            for( int ch = 0; ch < Output.Channels(); ++ch )
                Output( ch, el ) = buffer.Signal( ch, el );
            for( int ch = Output.Channels(); ch < buffer.Signal.Channels(); ++ch )
                State( labels[ch].c_str() + 1 )( el ) = static_cast<State::ValueType>( buffer.Signal( ch, el ) );
        }
    }
    State( "SourceTime" ) = buffer.TimeStamp;
}
开发者ID:ACrazyer,项目名称:NeuralSystemsBCI2000,代码行数:33,代码来源:BufferedADC.cpp

示例7:

void
DisplayFilter::Process( const GenericSignal& Input, GenericSignal& Output )
{
  if( Input.Channels() != mFilter.Channels() )
    mFilter.Initialize( Input.Channels() );
  mFilter.Process( Input, Output );
  if( mFilter.NanStalled() )
    mFilter.Initialize();
}
开发者ID:ACrazyer,项目名称:NeuralSystemsBCI2000,代码行数:9,代码来源:DisplayFilter.cpp

示例8: if

void
FFTFilter::Process( const GenericSignal& Input, GenericSignal& Output )
{
  if( mFFTOutputSignal == eInput )
    Output = Input;

  for( size_t i = 0; i < mFFTInputChannels.size(); ++i )
  {
    // Copy input signal values to the value buffer.
    vector<float>& buffer = mValueBuffers[ i ];
    int inputSize = Input.Elements(),
        bufferSize = static_cast<int>( buffer.size() );
    // Move old values towards the beginning of the buffer, if any.
    for( int j = 0; j < bufferSize - inputSize; ++j )
      buffer[ j ] = buffer[ j + inputSize ];
    // Copy new values to the end of the buffer;
    // buffer size may be greater or less than input size.
    for( int j = ::max( 0, bufferSize - inputSize ); j < bufferSize; ++j )
      buffer[ j ] = static_cast<float>( Input( mFFTInputChannels[ i ], j + inputSize - bufferSize ) );
    // Prepare the buffer.
    if( mFFTWindow == eNone )
      for( int j = 0; j < bufferSize; ++j )
        mFFT.Input( j ) = buffer[ j ];
    else
      for( int j = 0; j < bufferSize; ++j )
        mFFT.Input( j ) = buffer[ j ] * mWindow[ j ];
    // Compute the power spectrum and visualize it if requested.
    mFFT.Compute();
    if( mVisualizeFFT || mFFTOutputSignal == ePower )
    {
      int maxIdx = mPowerSpectrum.Channels() - 1;
      double normFactor = 1.0 / bufferSize;
      mPowerSpectrum( maxIdx, 0 ) = mFFT.Output( 0 ) * mFFT.Output( 0 ) * normFactor;
      for( int k = 1; k < ( bufferSize + 1 ) / 2; ++k )
        mPowerSpectrum( maxIdx - k, 0 ) = (
          mFFT.Output( k ) * mFFT.Output( k ) +
          mFFT.Output( bufferSize - k ) * mFFT.Output( bufferSize - k ) ) * normFactor;
      if( bufferSize % 2 == 0 )
        mPowerSpectrum( maxIdx - bufferSize / 2, 0 )
          = mFFT.Output( bufferSize / 2 ) * mFFT.Output( bufferSize / 2 ) * normFactor;
    }
    if( mVisualizeFFT )
      mVisualizations[ i ].Send( mPowerSpectrum );

    if( mFFTOutputSignal == ePower )
    {
      for( int j = 0; j < Output.Elements(); ++j )
        Output( i, j ) = mPowerSpectrum( mPowerSpectrum.Channels() - 1 - j, 0 );
    }
    else if( mFFTOutputSignal == eHalfcomplex )
    {
      double normFactor = 1.0 / ::sqrt( 1.0 * bufferSize );
      for( int j = 0; j < Output.Elements(); ++j )
        Output( i, j ) = mFFT.Output( j ) * normFactor;
    }
  }
}
开发者ID:ACrazyer,项目名称:NeuralSystemsBCI2000,代码行数:57,代码来源:FFTFilter.cpp

示例9: Output

void
LinearClassifier::Process( const GenericSignal& Input, GenericSignal& Output )
{
  for( int ch = 0; ch < Output.Channels(); ++ch )
    for( int el = 0; el < Output.Elements(); ++el )
      Output( ch, el ) = 0.0;

  for( size_t i = 0; i < mWeights.size(); ++i )
    Output( mOutputChannels[ i ], 0 )
      += Input( mInputChannels[ i ], mInputElements[ i ] ) * mWeights[ i ];
}
开发者ID:el-fran,项目名称:weka-bci2000,代码行数:11,代码来源:LinearClassifier.cpp

示例10: inSignal

void
EDFFileWriterBase::PutBlock( const GenericSignal& inSignal, const StateVector& inStatevector )
{
  for( int i = 0; i < inSignal.Channels(); ++i )
    for( int j = 0; j < inSignal.Elements(); ++j )
      GDF::Num<T>( inSignal( i, j ) ).WriteToStream( OutputStream() );
  for( size_t i = 0; i < mStateNames.size(); ++i )
    GDF::PutField< GDF::Num<GDF::int16> >(
      OutputStream(),
      inStatevector.StateValue( mStateNames[ i ] )
    );
}
开发者ID:el-fran,项目名称:weka-bci2000,代码行数:12,代码来源:EDFFileWriterBase.cpp

示例11: if

void
RDAClientADC::DoAcquire( GenericSignal& Output )
{
  if( !mConnection.ReceiveData( Output ) )
    Error( "Lost connection to VisionRecorder software" );
  else if( mAddMarkerChannel )
  {
    int from = Output.Channels() - 2,
        to = from + 1;
    for( int el = 0; el < Output.Elements(); ++el )
      Output( to, el ) = Output( from, el );
  }
}
开发者ID:ACrazyer,项目名称:NeuralSystemsBCI2000,代码行数:13,代码来源:RDAClientADC.cpp

示例12: Input

void
SpatialFilter::Process( const GenericSignal& Input, GenericSignal& Output )
{
  // Actually perform Spatial Filtering on the input and write it into the output signal.
  for( int sample = 0; sample < Input.Elements(); ++sample )
    for( int outChannel = 0; outChannel < Output.Channels(); ++outChannel )
    {
      double value = 0;
      for( int inChannel = 0; inChannel < Input.Channels(); ++inChannel )
        value += mFilterMatrix[ outChannel ][ inChannel ] * Input( inChannel, sample );
      Output( outChannel, sample ) = value;
    }
}
开发者ID:el-fran,项目名称:weka-bci2000,代码行数:13,代码来源:SpatialFilter.cpp

示例13: Idle

void
BrainVisionGDRConverter::OutputSignal( const GenericSignal& inSignal, long /*inSamplePos*/ )
{
  Idle();
  for( int sample = 0; sample < inSignal.Elements(); ++sample )
    for( int channel = 0; channel < inSignal.Channels(); ++channel )
    {
      float value = inSignal( channel, sample );
      mDataFile.write( reinterpret_cast<const char*>( &value ), sizeof( value ) );
    }

  if( !mDataFile )
    bcierr << "Error writing data file" << endl;
}
开发者ID:el-fran,项目名称:weka-bci2000,代码行数:14,代码来源:BrainVisionConverter.cpp

示例14: Output

void
RDAClientADC::Process( const GenericSignal&, GenericSignal& Output )
{
  for( int sample = 0; sample < Output.Elements(); ++sample )
    for( int channel = 0; channel < Output.Channels(); ++channel )
    {
      if( !mInputQueue )
      {
        bcierr << "Lost connection to VisionRecorder software" << endl;
        return;
      }
      Output( channel, sample ) = mInputQueue.front();
      mInputQueue.pop();
    }
}
开发者ID:el-fran,项目名称:weka-bci2000,代码行数:15,代码来源:RDAClientADC.cpp

示例15: Output

void
AlignmentFilter::Process( const GenericSignal& Input, GenericSignal& Output )
{
  if( mAlign ) // Perform the alignment on the input and write it into the output signal.
    for( int channel = 0; channel < Input.Channels(); ++channel )
      for( int sample = 0; sample < Input.Elements(); ++sample )
      {
        Output( channel, sample ) =
          Input( channel, sample ) * mWeightCur[ channel ]
            + mWeightPrev[ channel ] * mPrevSample[ channel ];
        mPrevSample[ channel ] = Input( channel, sample );
      }
  else // No alignment.
    Output = Input;
}
开发者ID:el-fran,项目名称:weka-bci2000,代码行数:15,代码来源:AlignmentFilter.cpp


注:本文中的GenericSignal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。