Beispiel #1
0
//virtual
bool
datafile::getSpectrum( int fcn, size_t pos, adcontrols::MassSpectrum& ms, uint32_t objId ) const
{
	(void)fcn;

	try {
		EDAL::IMSSpectrumCollectionPtr pSpectra = pAnalysis_->GetMSSpectrumCollection();
		EDAL::IMSSpectrumPtr pSpectrum = pSpectra->GetItem( long(pos) + 1 ); // 1-origin

		if ( pSpectrum->Polarity == EDAL::SpectrumPolarity::IonPolarity_Negative )
			ms.setPolarity( adcontrols::MS_POLARITY::PolarityNegative );
		else if ( pSpectrum->Polarity == EDAL::SpectrumPolarity::IonPolarity_Positive )
			ms.setPolarity( adcontrols::MS_POLARITY::PolarityPositive );
		else
			ms.setPolarity( adcontrols::MS_POLARITY::PolarityIndeterminate );

		adcontrols::MSProperty prop = ms.getMSProperty();
		prop.setTimeSinceInjection( static_cast< unsigned long >( pSpectrum->RetentionTime /* sec */ * 1.0e6 ) ); // usec
        ms.setMSProperty( prop ); // <- end of prop set

		_variant_t vMasses, vIntens;
        if ( objId <= 1 ) {
			pSpectrum->GetMassIntensityValues( EDAL::SpectrumType_Profile, &vMasses, &vIntens );
			ms.setCentroid( adcontrols::CentroidNone );  // profile
        } else { // objId should be 2
			pSpectrum->GetMassIntensityValues( EDAL::SpectrumType_Line, &vMasses, &vIntens );
			ms.setCentroid( adcontrols::CentroidNative );
		}

		SafeArray sa_masses( vMasses );
        ms.resize( sa_masses.size() );
        ms.setMassArray( reinterpret_cast< const double *>( sa_masses.p() ) );
    
		SafeArray sa_intensities( vIntens );
        ms.setIntensityArray( reinterpret_cast< const double *>( sa_intensities.p() ) );

        ms.setAcquisitionMassRange( ms.getMass( 0 ), ms.getMass( ms.size() - 1 ) );

		return true;
	} catch(_com_error& ex ) {
		ADERROR() << std::wstring( ex.ErrorMessage() );
		return false;
	}
	return false;
}
Beispiel #2
0
bool
waveform::fft::lowpass_filter( adcontrols::MassSpectrum& ms, double freq )
{
    if ( ms.isCentroid() )
        return false;

    size_t totalSize = ms.size();
	(void)totalSize;
	size_t N = 32;
    while ( N < ms.size() )
		N *= 2;
	const size_t NN = ms.size();
	double sampInterval = ms.getMSProperty().getSamplingInfo().fSampInterval(); // seconds
    if ( sampInterval == 0 )
        sampInterval = ( ms.getTime( ms.size() - 1 ) - ms.getTime( 0 ) ) / ms.size();
    const double T = N * sampInterval;  // time full scale in seconds.  Freq = n/T (Hz)
    // power spectrum has N/2 points and is n/T Hz horizontal axis  := data[N/2] = (N/2)/T Hz
    size_t cutoff = size_t( T * freq );

	adportable::array_wrapper<const double> pIntens( ms.getIntensityArray(), N );

	std::vector< std::complex<double> > spc( N );
	std::vector< std::complex<double> > fft( N );
	size_t n;
	for ( n = 0; n < N && n < NN; ++n )
		spc[ n ] = std::complex<double>( pIntens[ n ] );
	while ( n < N )
		spc[ n++ ] = pIntens[ NN - 1 ];

	adportable::fft::fourier_transform( fft, spc, false );
    // appodization
    for ( size_t i = cutoff; i < N - cutoff; ++i )
        fft[ i ] = 0;
    //adportable::fft::apodization( N/2 - N/16, N / 16, fft );
	adportable::fft::fourier_transform( spc, fft, true );

	std::vector<double> data( N );
	for ( size_t i = 0; i < NN; ++i )
		data[ i ] = spc[i].real();

	ms.setIntensityArray( &data[0] );

	return true;
}
Beispiel #3
0
//virtual
bool
datafile::getSpectrum( int /* fcn*/, size_t idx, adcontrols::MassSpectrum& ms, uint32_t /* objid */) const
{
    if ( lrpfile_ && unsigned( idx ) < lrpfile_->number_of_spectra() ) {

        if ( auto msdata = (*lrpfile_)[ idx ] ) {

            std::vector< double > time, intens;
            if ( lrpfile_->getMS( *msdata, time, intens ) ) {

                ms.resize( time.size() );
                ms.setMassArray( time.data() );
                ms.setIntensityArray( intens.data() );

                ms.setAcquisitionMassRange( time.front(), time.back() );

                return true;
            }
        }
    }
    return false;
}