コード例 #1
0
void
BCI2000Viewer::UpdateChannelLabels()
{
  if( mFile.IsOpen() )
  {
    vector<string> signalLabels;
    if( mFile.Parameters()->Exists( "ChannelNames" ) )
    {
      ParamRef labelParam = mFile.Parameter( "ChannelNames" );
      for( int k = 0; k < labelParam->NumValues(); ++k )
        signalLabels.push_back( labelParam( k ) );
    }
    for( int i = static_cast<int>( signalLabels.size() ); i < mFile.SignalProperties().Channels(); ++i )
    {
      ostringstream oss;
      oss << i + 1;
      signalLabels.push_back( oss.str() );
    }

    LabelList channelLabels;
    int numMarkerChannels = 0;
    int j = 1;
    while( j < ui->channelList->count()
           && ( ui->channelList->item( j )->flags() & Qt::ItemIsUserCheckable ) )
      ++j;
    int chBase = ++j;
    for( ; j < ui->channelList->count()
           && ( ui->channelList->item( j )->flags() & Qt::ItemIsUserCheckable ); ++j )
      if( ui->channelList->item( j )->checkState() == Qt::Checked )
        channelLabels.push_back(
          Label(
            static_cast<int>( channelLabels.size() ),
            signalLabels[ j - chBase ]
          )
        );
    for( int i = 1; i < ui->channelList->count()
                    && ( ui->channelList->item( i )->flags() & Qt::ItemIsUserCheckable ); ++i )
      if( ui->channelList->item( i )->checkState() == Qt::Checked )
      {
        channelLabels.push_back(
          Label(
            static_cast<int>( channelLabels.size() ),
            ui->channelList->item( i )->text().toLocal8Bit().constData()
          )
        );
        ++numMarkerChannels;
      }
    mNumSignalChannels = static_cast<int>( channelLabels.size() ) - numMarkerChannels;
    ui->signalDisplay->Display().SetNumMarkerChannels( numMarkerChannels )
                                .SetChannelLabels( channelLabels )
                                .SetChannelLabelsVisible( true );
  }
  else
  {
    mNumSignalChannels = 0;
    ui->signalDisplay->Display().SetNumMarkerChannels( 0 )
                                .SetChannelLabels( LabelList() );
  }
}
コード例 #2
0
ファイル: assumptionsblock.cpp プロジェクト: goshng/treeviewx
/**
 * @method GetCharSetNames [void:public]
 * @param names [LabelList&] the vector in which to store the names
 *
 * Erases names, then fills names with the names of all stored
 * character sets.
 */
void AssumptionsBlock::GetCharSetNames( LabelList& names )
{
	names.erase( names.begin(), names.end() );
   IntSetMap::const_iterator i;
   for( i = charsets.begin(); i != charsets.end(); i++ )
		names.push_back( (*i).first );
}
コード例 #3
0
ファイル: offlinejob.cpp プロジェクト: snakamura/q3
std::auto_ptr<OfflineJob> qmimap4::SetLabelOfflineJob::create(InputStream* pStream)
{
	wstring_ptr wstrFolder;
	READ_STRING(WSTRING, wstrFolder);
	if (!wstrFolder.get())
		return std::auto_ptr<OfflineJob>(0);
	
	unsigned int nSize = 0;
	READ(&nSize, sizeof(nSize));
	if (nSize == 0)
		return std::auto_ptr<OfflineJob>(0);
	UidList listUid;
	listUid.resize(nSize);
	READ(&listUid[0], nSize*sizeof(UidList::value_type));
	
	wstring_ptr wstrLabel;
	READ_STRING(WSTRING, wstrLabel);
	
	unsigned int nLabelSize = 0;
	READ(&nLabelSize, sizeof(nLabelSize));
	LabelList listLabel;
	listLabel.reserve(nLabelSize);
	CONTAINER_DELETER(free, listLabel, &freeWString);
	for (unsigned int n = 0; n < nLabelSize; ++n) {
		wstring_ptr wstrLabel;
		READ_STRING(WSTRING, wstrLabel);
		listLabel.push_back(wstrLabel.release());
	}
	
	return std::auto_ptr<OfflineJob>(new SetLabelOfflineJob(wstrFolder.get(), listUid,
		wstrLabel.get(), const_cast<const WCHAR**>(&listLabel[0]), listLabel.size()));
}
コード例 #4
0
ファイル: X86CodeGen.cpp プロジェクト: ktok07b6/tiger
void 
X86CodeGen::munchJUMP(Label *lab)
{
	LabelList targets;
	targets.push_back(lab);
	assem::OPER *op = _aOPER("jmp", "'j0", NULL, NULL);
	op->setJumpTargets(targets);
	emit(op);
}
コード例 #5
0
ファイル: X86CodeGen.cpp プロジェクト: ktok07b6/tiger
void 
X86CodeGen::munchCJUMP(tree::CJUMP *cj)
{
	tree::CONST *konst;
	std::string assem;
	TempList tsrc;

	const char *cond[] = {"e", "ne", 
						  "l", "g", 
						  "le", "ge"
	};
	//reverse condition for less or greater
	const char *cond_r[] = {"e", "ne", 
							"ge", "le", 
							"g", "l"
	};
	bool reverse = false;
	if (_M0(CONST_T, konst) == cj->l) {
		assem = format("$%d, 's0", konst->value);
		tsrc.push_back(munchExp(cj->r));
		reverse = true;
	} else if (_M0(CONST_T, konst) == cj->r) {
		assem = format("$%d, 's0", konst->value);
		tsrc.push_back(munchExp(cj->l));
	} else {
		assem = "'s1, 's0";
		tsrc.push_back(munchExp(cj->l));
		tsrc.push_back(munchExp(cj->r));
	}
	emit(_aOPER("cmpl", assem, TempList(), tsrc));
	LabelList targets;
	targets.push_back(cj->truelab);
	targets.push_back(cj->falselab);
	assem = format("j%s", reverse ? cond_r[cj->relop] : cond[cj->relop]);
	assem::OPER *op = _aOPER(assem, "'j0", NULL, NULL);
	op->setJumpTargets(targets);
	emit(op);
}
コード例 #6
0
ファイル: X86CodeGen.cpp プロジェクト: ktok07b6/tiger
void
X86CodeGen::munchEXPR(tree::Exp *exp)
{
	tree::CALL *call;
	if (_M0(CALL_T, call) == exp) {
		TempList tsrc;
		munchArgs(call->args, &tsrc);

		LabelList targets;
		targets.push_back(call->func->label);
		//eax, ecx, edx will be destoryed in c function
		assem::OPER *op = _aOPER("call", "'j0", frame->registers().callerSaves, tsrc);
		op->setJumpTargets(targets);
		emit(op);
	}
}
コード例 #7
0
void
AverageDisplay::Initialize( const SignalProperties&, const SignalProperties& )
{
  for( size_t i = 0; i < mVisualizations.size(); ++i )
    mVisualizations[ i ].Send( CfgID::Visible, false );
  mVisualizations.clear();
  mChannelIndices.clear();
  mPowerSums.clear();
  mTargetCodes.clear();
  mSignalOfCurrentRun.clear();
#ifdef SET_BASELINE
  mBaselines.clear();
  mBaselineSamples.clear();
#endif // SET_BASELINE
  LabelList markerLabels;
  for( int i = 0; i < Parameter( "AvgDisplayMarkers" )->NumRows(); ++i )
  {
    string markerName = Parameter( "AvgDisplayMarkers" )( i, 0 );
    int position =
      MeasurementUnits::ReadAsTime( OptionalParameter( markerName, -1 ) )
                                               * Parameter( "SampleBlockSize" );
    if( position >= 0 )
      markerLabels.push_back( Label( position, markerName ) );
  }

  int numChannels = Parameter( "AvgDisplayCh" )->NumRows();
  mPowerSums.resize( maxPower + 1, vector<vector<vector<float> > >( numChannels ) );
  for( int i = 0; i < numChannels; ++i )
  {
    ostringstream oss;
    oss << "AVG" << i;
    mVisualizations.push_back( GenericVisualization( oss.str() ) );
    GenericVisualization& vis = mVisualizations[ i ];

    string windowTitle = Parameter( "AvgDisplayCh" )( i, 1 );
    if( windowTitle == "" )
      windowTitle = "unknown";
    windowTitle += " Average";
    vis.Send( CfgID::WindowTitle, windowTitle );
    // Note min and max value are interchanged to account for EEG display direction.
    vis.Send( CfgID::MinValue, int( Parameter( "AvgDisplayMin" ) ) );
    vis.Send( CfgID::MaxValue, int( Parameter( "AvgDisplayMax" ) ) );
    vis.Send( CfgID::NumSamples, 0 );
    vis.Send( CfgID::GraphType, CfgID::Polyline );

    if( !markerLabels.empty() )
      vis.Send( CfgID::XAxisMarkers, markerLabels );

    ColorList channelColors( sChannelColors );
    vis.Send( CfgID::ChannelColors, channelColors );

    vis.Send( CfgID::ChannelGroupSize, 0 );
    vis.Send( CfgID::ShowBaselines, 1 );
    vis.Send( CfgID::Visible, true );

    mChannelIndices.push_back( Parameter( "AvgDisplayCh" )( i, 0 ) - 1 );
  }

  mSignalOfCurrentRun.resize( numChannels );
#ifdef SET_BASELINE
  mBaselines.resize( numChannels );
  mBaselineSamples.resize( numChannels );
#endif // SET_BASELINE
  mLastTargetCode = 0;
}
コード例 #8
0
void
AverageDisplay::Process( const GenericSignal& Input, GenericSignal& Output )
{
  size_t targetCode = State( "TargetCode" );
  if( targetCode == 0 && targetCode != mLastTargetCode )
  {
    size_t targetIndex = find( mTargetCodes.begin(), mTargetCodes.end(), mLastTargetCode ) - mTargetCodes.begin();
    if( targetIndex == mTargetCodes.size() )
      mTargetCodes.push_back( mLastTargetCode );
    // End of the current target code run.
    for( size_t i = 0; i < mChannelIndices.size(); ++i )
    {
      for( int power = 0; power <= maxPower; ++power )
      {
        // - If the target code occurred for the first time, adapt the power sums.
        if( mPowerSums[ power ][ i ].size() <= targetIndex )
          mPowerSums[ power ][ i ].resize( targetIndex + 1 );
        // - Update power sum sizes.
        if( mPowerSums[ power ][ i ][ targetIndex ].size() < mSignalOfCurrentRun[ i ].size() )
          mPowerSums[ power ][ i ][ targetIndex ].resize( mSignalOfCurrentRun[ i ].size(), 0 );
      }
#ifdef SET_BASELINE
      if( mBaselineSamples[ i ] > 0 )
        mBaselines[ i ] /= mBaselineSamples[ i ];
#endif // SET_BASELINE
      // - Compute the power sum entries.
      for( size_t j = 0; j < mSignalOfCurrentRun[ i ].size(); ++j )
      {
#ifdef SET_BASELINE
        mSignalOfCurrentRun[ i ][ j ] -= mBaselines[ i ];
#endif // SET_BASELINE
        float summand = 1.0;
        for( size_t power = 0; power < maxPower; ++power )
        {
          mPowerSums[ power ][ i ][ targetIndex ][ j ] += summand;
          summand *= mSignalOfCurrentRun[ i ][ j ];
        }
        mPowerSums[ maxPower ][ i ][ targetIndex ][ j ] += summand;
      }
    }
    // - Clear target run buffer.
    for( size_t i = 0; i < mSignalOfCurrentRun.size(); ++i )
      mSignalOfCurrentRun[ i ].clear();
#ifdef SET_BASELINE
    for( size_t i = 0; i < mBaselines.size(); ++i )
    {
      mBaselineSamples[ i ] = 0;
      mBaselines[ i ] = 0;
    }
#endif // SET_BASELINE
    // - Compute and display the averages.
    for( size_t channel = 0; channel < mVisualizations.size(); ++channel )
    {
      size_t numTargets = mPowerSums[ maxPower ][ channel ].size(),
             numSamples = numeric_limits<size_t>::max();
      for( size_t target = 0; target < numTargets; ++target )
        if( mPowerSums[ maxPower ][ channel ][ target ].size() < numSamples )
          numSamples = mPowerSums[ maxPower ][ channel ][ target ].size();

      // To minimize user confusion, always send target averages in ascending order
      // of target codes. This ensures that colors in the display don't depend
      // on the order of target codes in the task sequence once all target codes
      // occurred.
      // We cannot, however, avoid color changes when yet unknown target codes
      // occur.
      //
      // The map is automatically sorted by its "key", so all we need to do
      // is to put the target codes and their indices into it, using the
      // target code as "key" and the index as "value", and later iterate over
      // the map to get the indices sorted by their associated target code.
      map<int, int> targetCodesToIndex;
      for( size_t target = 0; target < numTargets; ++target )
        targetCodesToIndex[ mTargetCodes[ target ] ] = target;

      GenericSignal average( numTargets, numSamples );
      LabelList     labels;
      for( map<int, int>::const_iterator target = targetCodesToIndex.begin();
                                   target != targetCodesToIndex.end(); ++target )
      {
        for( size_t sample = 0; sample < numSamples; ++sample )
          // If everything behaves as we believe it will,
          // a division by zero is impossible.
          // If it occurs nevertheless, the logic is messed up.
          average( target->second, sample ) =
            mPowerSums[ 1 ][ channel ][ target->second ][ sample ] /
                          mPowerSums[ 0 ][ channel ][ target->second ][ sample ];
        ostringstream oss;
        oss << "Target " << target->first;
        string targetName = OptionalParameter( "TargetNames", target->first );
        if( targetName != "" )
          oss << " (" << targetName << ")";
        labels.push_back( Label( target->second, oss.str() ) );
      }
      mVisualizations[ channel ].Send( CfgID::ChannelLabels, labels );
      ostringstream oss;
      oss << ( Parameter( "SampleBlockSize" )  / Input.Elements() / Parameter( "SamplingRate" ) ) << "s";
      mVisualizations[ channel ].Send( CfgID::SampleUnit, oss.str() );
      mVisualizations[ channel ].Send( average );
    }
  }
  if( targetCode != 0 )
  {
    // Store the current signal to the end of the run buffer.
    for( size_t i = 0; i < mChannelIndices.size(); ++i )
    {
      size_t signalCursorPos = mSignalOfCurrentRun[ i ].size();
      mSignalOfCurrentRun[ i ].resize( signalCursorPos + Input.Elements() );
      for( int j = 0; j < Input.Elements(); ++j )
        mSignalOfCurrentRun[ i ][ signalCursorPos + j ] = Input( mChannelIndices[ i ], j );
    }
#ifdef SET_BASELINE
    if( OptionalState( "BaselineInterval" ) || OptionalState( "Baseline" ) )
    {
      for( size_t i = 0; i < mChannelIndices.size(); ++i )
      {
        mBaselineSamples[ i ] += Input.Elements();
        for( int j = 0; j < Input.Elements(); ++j )
          mBaselines[ i ] += Input( mChannelIndices[ i ], j );
      }
    }
#endif // SET_BASELINE
  }
  mLastTargetCode = targetCode;
  Output = Input;
}