コード例 #1
0
        private Int32 ExtractFromBitsInt32(int packedValue, byte startBit, byte endBit)
        {
            int unpackedValue;

            if (endBit < 31)
            {
                if (startBit == 0)
                {
                    unpackedValue = (int)(packedValue & CreateMask(0, endBit));
                }
                else
                {
                    unpackedValue = (int)((long)(packedValue / Math.Pow(2, startBit)) & CreateMask(0, (byte)(endBit - startBit)));
                }
            }
            else
            {
                unpackedValue = (int)(NumberConversion.Int32ToUnsigned(packedValue) / Math.Pow(2, startBit));
            }

            return(unpackedValue);
        }
コード例 #2
0
        /// <summary>
        /// Extracts packed mass data
        /// </summary>
        /// <param name="packedBasePeakInfo"></param>
        /// <param name="acquisitionDataType"></param>
        /// <param name="processingFunctionIndexFile"></param>
        /// <returns></returns>
        public double UnpackMass(int packedBasePeakInfo, short acquisitionDataType, bool processingFunctionIndexFile)
        {
            // See note for Acquisition Data Types 9 to 12 below
            double unpackedMass;

            switch (acquisitionDataType)
            {
            case 9:
            case 10:
            case 11:
            case 12:
                // Includes type 9, 11, and 12; type 10 is officially unused
                //  (9=High accuracy calibrated data, 11=Enhanced uncalibrated data, and 12=Enhanced calibrated data)
                // Note: Only use this function to unpack masses for data in the .IDX file, not for data in the .DAT file
                //       See the NativeIOGetSpectrum function for the method of unpacking masses in .DAT files

                // Compute the MassMantissa value by converting the Packed value to an Unsigned Int32 (and storing in a long),
                //  then right shifting 9 bits by dividing by 2^9
                // It would be more straightforward to use packedBasePeakInfo And CreateMask(9, 31) but VB won't let us
                //  And a Currency value with a Long; this gives an OverFlow error
                var massMantissa = (int)(NumberConversion.Int32ToUnsigned(packedBasePeakInfo) / 512f);          // 512 = 2^9

                // Compute the MassExponent value by multiplying the Packed value by the appropriate BitMask, then right shifting 4 bits by dividing by 2^4
                var massExponent = (short)(packedBasePeakInfo & maskBPMassExponent) / 16f;                      // 16 = 2^4

                if (processingFunctionIndexFile)
                {
                    // When computing the BasePeakMass based on data in the _func001.idx
                    //  file, must bump up the Mass Exponent by 8 in order to multiply the
                    //  Mass Mantissa by an additional value of 256 to get the correct value
                    if (massExponent < 6)
                    {
                        if (acquisitionDataType == 9)
                        {
                            // This only seems to be necessary for files with Acquisition data type 9
                            // The following Assertion is here to test for that
                            massExponent += 8;
                        }
                    }
                }

                // Note that we divide by 2^23 to convert the mass mantissa to fractional form
                unpackedMass = massMantissa / 8388608f * Math.Pow(2, massExponent);          // 8388608 = 2^23
                break;

            case 0:
                // Compressed data
                // Compute the MassMantissa value by converting the Packed value to an Unsigned Int32 (and storing in a long),
                //  then right shifting 11 bits by dividing by 2^11
                // It would be more straightforward to use packedBasePeakInfo And CreateMask(11, 31) but VB won't let us
                //  And a Currency value with a Long; this gives an OverFlow error
                // We must divide the MassMantissa by 128 to get the mass
                unpackedMass = (int)(NumberConversion.Int32ToUnsigned(packedBasePeakInfo) / 2048f) / 128f;          // 2048 = 2^11
                // Debug.Assert(unpackedMass == ExtractFromBitsInt32(packedBasePeakInfo, 11, 31) / 128f);
                break;

            case 1:
                // Standard data
                // We must divide the MassMantissa by 1024 to get the mass
                unpackedMass = (short)(packedBasePeakInfo & maskBPStandardDataMass) / 1024f;
                break;

            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
                // Uncalibrated data
                // This type of data doesn't have a base peak mass
                unpackedMass = 0;
                break;

            case 8:
                // High intensity calibrated data
                // Compute the MassMantissa value by converting the Packed value to an Unsigned Int32 (and storing in a long),
                //  then right shifting 4 bits by dividing by 2^4
                // We must divide the MassMantissa by 128 to get the mass
                unpackedMass = (int)(NumberConversion.Int32ToUnsigned(packedBasePeakInfo) / 16f) / 128f;            // 16 = 2^4
                //Debug.Assert(unpackedMass == ExtractFromBitsInt32(packedBasePeakInfo, 4, 31) / 128f);
                break;

            default:
                unpackedMass = 0;
                break;
            }
            return(unpackedMass);
        }
コード例 #3
0
 public bool GetContainsCalibratedMasses(int packedScanInfo)
 {
     return(NumberConversion.ValueToBool(packedScanInfo & maskScanContainsCalibratedMasses));
 }
コード例 #4
0
 public bool GetContinuumDataOverride(int packedScanInfo)
 {
     return(NumberConversion.ValueToBool(packedScanInfo & maskContinuumDataOverride));
 }
コード例 #5
0
 public bool GetUseFollowingContinuum(int packedScanInfo)
 {
     return(NumberConversion.ValueToBool(packedScanInfo & maskUseFollowingContinuum));
 }
コード例 #6
0
 public short GetMSMSSegmentOrChannelCount(short packedMsMsInfo)
 {
     return((short)(NumberConversion.Int32ToUnsigned(packedMsMsInfo) / 256f));      // 256 = 2^8
 }