@@ -692,7 +692,7 @@ private List<ChromatogramType> ConstructChromatograms(int firstScanNumber, int l
692692 } ;
693693 timesBinaryData . encodedLength =
694694 ( 4 * Math . Ceiling ( ( double ) timesBinaryData
695- . binary . Length / 3 ) ) . ToString ( CultureInfo . InvariantCulture ) ;
695+ . binary . Length / 3 ) ) . ToString ( CultureInfo . InvariantCulture ) ;
696696 var timesBinaryDataCvParams = new List < CVParamType >
697697 {
698698 new CVParamType
@@ -745,7 +745,7 @@ private List<ChromatogramType> ConstructChromatograms(int firstScanNumber, int l
745745 } ;
746746 intensitiesBinaryData . encodedLength =
747747 ( 4 * Math . Ceiling ( ( double ) intensitiesBinaryData
748- . binary . Length / 3 ) ) . ToString ( CultureInfo . InvariantCulture ) ;
748+ . binary . Length / 3 ) ) . ToString ( CultureInfo . InvariantCulture ) ;
749749 var intensitiesBinaryDataCvParams = new List < CVParamType >
750750 {
751751 new CVParamType
@@ -969,37 +969,57 @@ private SpectrumType ConstructSpectrum(int scanNumber)
969969 double ? highestObservedMz = null ;
970970 double [ ] masses = null ;
971971 double [ ] intensities = null ;
972- if ( scan . HasCentroidStream && ( scanEvent . ScanData == ScanDataType . Centroid ||
973- ( scanEvent . ScanData == ScanDataType . Profile &&
974- ! ParseInput . NoPeakPicking ) ) )
972+
973+ if ( ! ParseInput . NoPeakPicking )
975974 {
976- var centroidStream = _rawFile . GetCentroidStream ( scanNumber , false ) ;
977- if ( scan . CentroidScan . Length > 0 )
975+ spectrumCvParams . Add ( new CVParamType
978976 {
979- spectrumCvParams . Add ( new CVParamType
977+ accession = "MS:1000127" ,
978+ cvRef = "MS" ,
979+ name = "centroid spectrum" ,
980+ value = ""
981+ } ) ;
982+
983+ // Check if the scan has a centroid stream
984+ if ( scan . HasCentroidStream )
985+ {
986+ if ( scan . CentroidScan . Length > 0 )
980987 {
981- accession = "MS:1000127" ,
982- cvRef = "MS" ,
983- name = "centroid spectrum" ,
984- value = ""
985- } ) ;
988+ basePeakMass = scan . CentroidScan . BasePeakMass ;
989+ basePeakIntensity = scan . CentroidScan . BasePeakIntensity ;
990+ lowestObservedMz = scan . CentroidScan . Masses [ 0 ] ;
991+ highestObservedMz = scan . CentroidScan . Masses [ scan . CentroidScan . Masses . Length - 1 ] ;
992+ masses = scan . CentroidScan . Masses ;
993+ intensities = scan . CentroidScan . Intensities ;
994+ }
995+ }
996+ else // otherwise take the profile data
997+ {
998+ basePeakMass = scan . ScanStatistics . BasePeakMass ;
999+ basePeakIntensity = scan . ScanStatistics . BasePeakIntensity ;
9861000
987- basePeakMass = centroidStream . BasePeakMass ;
988- basePeakIntensity = centroidStream . BasePeakIntensity ;
989- lowestObservedMz = centroidStream . Masses [ 0 ] ;
990- highestObservedMz = centroidStream . Masses [ centroidStream . Masses . Length - 1 ] ;
991- masses = centroidStream . Masses ;
992- intensities = centroidStream . Intensities ;
1001+ // Get the segmented (low res and profile) scan data
1002+ // if the spectrum is profile perform centroiding
1003+ var segmentedScan = scanEvent . ScanData == ScanDataType . Profile
1004+ ? Scan . ToCentroid ( scan ) . SegmentedScan
1005+ : scan . SegmentedScan ;
1006+
1007+ if ( segmentedScan . PositionCount > 0 )
1008+ {
1009+ lowestObservedMz = segmentedScan . Positions [ 0 ] ;
1010+ highestObservedMz = segmentedScan . Positions [ segmentedScan . PositionCount - 1 ] ;
1011+ masses = segmentedScan . Positions ;
1012+ intensities = segmentedScan . Intensities ;
1013+ }
9931014 }
9941015 }
995- else
1016+ else // use the profile data as is
9961017 {
9971018 basePeakMass = scan . ScanStatistics . BasePeakMass ;
9981019 basePeakIntensity = scan . ScanStatistics . BasePeakIntensity ;
9991020
1000- // centroid the profile data by default
1001- var segmentedScan = ! ParseInput . NoPeakPicking ? Scan . ToCentroid ( scan ) . SegmentedScan : scan . SegmentedScan ;
1002- if ( segmentedScan . Positions . Length > 0 )
1021+ // Get the segmented (low res and profile) scan data
1022+ if ( scan . SegmentedScan . Positions . Length > 0 )
10031023 {
10041024 switch ( scanEvent . ScanData )
10051025 {
@@ -1023,10 +1043,10 @@ private SpectrumType ConstructSpectrum(int scanNumber)
10231043 break ;
10241044 }
10251045
1026- lowestObservedMz = segmentedScan . Positions [ 0 ] ;
1027- highestObservedMz = segmentedScan . Positions [ segmentedScan . Positions . Length - 1 ] ;
1028- masses = segmentedScan . Positions ;
1029- intensities = segmentedScan . Intensities ;
1046+ lowestObservedMz = scan . SegmentedScan . Positions [ 0 ] ;
1047+ highestObservedMz = scan . SegmentedScan . Positions [ scan . SegmentedScan . Positions . Length - 1 ] ;
1048+ masses = scan . SegmentedScan . Positions ;
1049+ intensities = scan . SegmentedScan . Intensities ;
10301050 }
10311051 }
10321052
@@ -1109,7 +1129,7 @@ private SpectrumType ConstructSpectrum(int scanNumber)
11091129 } ;
11101130 massesBinaryData . encodedLength =
11111131 ( 4 * Math . Ceiling ( ( double ) massesBinaryData
1112- . binary . Length / 3 ) ) . ToString ( CultureInfo . InvariantCulture ) ;
1132+ . binary . Length / 3 ) ) . ToString ( CultureInfo . InvariantCulture ) ;
11131133 var massesBinaryDataCvParams = new List < CVParamType >
11141134 {
11151135 new CVParamType
@@ -1159,7 +1179,7 @@ private SpectrumType ConstructSpectrum(int scanNumber)
11591179 } ;
11601180 intensitiesBinaryData . encodedLength =
11611181 ( 4 * Math . Ceiling ( ( double ) intensitiesBinaryData
1162- . binary . Length / 3 ) ) . ToString ( CultureInfo . InvariantCulture ) ;
1182+ . binary . Length / 3 ) ) . ToString ( CultureInfo . InvariantCulture ) ;
11631183 var intensitiesBinaryDataCvParams = new List < CVParamType >
11641184 {
11651185 new CVParamType
0 commit comments