changeset 3:36d38d2cf88c draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/MALDIquant commit f127be2141cf22e269c85282d226eb16fe14a9c1
author galaxyp
date Fri, 15 Feb 2019 10:26:45 -0500
parents 17c54820f3be
children e9300ef37403
files maldi_macros.xml maldi_quant_peakdetection.xml test-data/Preprocessing1_QC.pdf test-data/Preprocessing2_QC.pdf test-data/Preprocessing3_QC.pdf test-data/align_reference_test2.tabular test-data/inputpeptides.tabular test-data/outfile1.ibd test-data/outfile1.imzML test-data/outfile1.imzml test-data/outfile2.ibd test-data/outfile2.imzML test-data/outfile2.imzml test-data/outfile3.ibd test-data/outfile3.imzML test-data/outfile3.imzml test-data/peak_detection1.imzml.txt test-data/peak_detection2.ibd test-data/peak_detection2.imzml test-data/peak_detection2.imzml.txt test-data/peak_detection3.ibd test-data/peak_detection3.imzml test-data/peak_detection3.imzml.txt test-data/peak_detection4.ibd test-data/peak_detection4.imzml test-data/peak_detection4.imzml.txt test-data/peakdetection1_QC.pdf test-data/peakdetection2_QC.pdf test-data/peakdetection3_QC.pdf test-data/peakdetection4_QC.pdf test-data/preprocessing1.imzml.txt test-data/preprocessing2.imzml.txt test-data/preprocessing3.imzml.txt
diffstat 33 files changed, 2347 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/maldi_macros.xml	Thu Oct 25 07:32:17 2018 -0400
+++ b/maldi_macros.xml	Fri Feb 15 10:26:45 2019 -0500
@@ -18,11 +18,12 @@
 
     <xml name="requirements">
         <requirements>
-            <requirement type="package" version="1.10.0">bioconductor-cardinal</requirement>
+            <requirement type="package" version="3.5.1">r-base</requirement>
+            <requirement type="package" version="1.12.1">bioconductor-cardinal</requirement>
             <requirement type="package" version="0.11.5">r-maldiquantforeign</requirement>
             <requirement type="package" version="1.18">r-maldiquant</requirement>
-            <requirement type="package" version="2.2.1">r-ggplot2</requirement>
-            <requirement type="package" version="2.2.1">r-gridextra</requirement>
+            <requirement type="package" version="3.0">r-ggplot2</requirement>
+            <requirement type="package" version="2.3">r-gridextra</requirement>
         </requirements>
     </xml>
 
--- a/maldi_quant_peakdetection.xml	Thu Oct 25 07:32:17 2018 -0400
+++ b/maldi_quant_peakdetection.xml	Fri Feb 15 10:26:45 2019 -0500
@@ -1,4 +1,4 @@
-<tool id="maldi_quant_peak_detection" name="MALDIquant peak detection" version="@VERSION@.2">
+<tool id="maldi_quant_peak_detection" name="MALDIquant peak detection" version="@VERSION@.3">
     <description>
         Peak detection, binning and filtering for mass-spectrometry imaging data
     </description>
@@ -37,6 +37,7 @@
 
     ## Import imzML file
     coordinate_matrix = as.matrix(read.delim("$restriction_conditional.coordinates_file", header = $restriction_conditional.coordinates_header, stringsAsFactors = FALSE))[,1:2]
+    coordinate_matrix = coordinate_matrix[,c($restriction_conditional.column_x, $restriction_conditional.column_y)]
 
     maldi_data <- importImzMl('infile.imzML',
                      coordinates = coordinate_matrix, centroided = $centroids)
@@ -99,15 +100,16 @@
             cardinal_mzs = Cardinal::mz(msidata)
             maldi_data = list()
             for(number_spectra in 1:ncol(msidata)){
-                maldi_data[[number_spectra]] = createMassSpectrum(mass = cardinal_mzs, intensity = iData(msidata)[,number_spectra])
-                coordinates_info = cbind(cardinal_coordinates, c(1:length(maldi_data)))}
+                maldi_data[[number_spectra]] = createMassSpectrum(mass = cardinal_mzs, intensity = iData(msidata)[,number_spectra])}
+            coordinates_info = cbind(cardinal_coordinates, c(1:length(maldi_data)))
         }else{
             peaks = list()
             for (spectra in 1:ncol(msidata))
             {
                 single_peaks = createMassPeaks(Cardinal::mz(msidata), Cardinal::spectra(msidata)[,spectra], snr=as.numeric(rep("NA", nrow(msidata))))
                 peaks[[spectra]] = single_peaks
-            }}
+            }
+            coordinates_info = cbind(cardinal_coordinates, c(1:length(peaks)))}
     #end if
 #end if
 
@@ -125,10 +127,20 @@
 
 ## plot input file spectrum: 
 #if $centroids:
-        plot(peaks[[1]], main="First spectrum of input file")
+    ## Choose random spectra for QC plots
+    random_spectra = sample(1:length(peaks), 4, replace=FALSE)
+    par(mfrow = c(2, 2), oma=c(0,0,2,0))
+    for (random_sample in random_spectra){
+        plot(peaks[[random_sample]],sub="", main=paste0("spectrum ", random_sample))}
+    title("Input spectra", outer=TRUE, line=0)
+
 #else
-    avgSpectra <- averageMassSpectra(maldi_data,method="mean")
-    plot(avgSpectra, main="Average spectrum of input file")
+    ## Choose random spectra for QC plots
+    random_spectra = sample(1:length(maldi_data), 4, replace=FALSE)
+    par(mfrow = c(2, 2), oma=c(0,0,2,0))
+    for (random_sample in random_spectra){
+        plot(maldi_data[[random_sample]],sub="", main=paste0("spectrum ", random_sample))}
+    title("Input spectra", outer=TRUE, line=0)
 #end if
 
 
@@ -162,10 +174,11 @@
     annotation_input = input_tabular[,c($tabular_annotation.column_x, $tabular_annotation.column_y, $tabular_annotation.column_names)]
     colnames(annotation_input) = c("x", "y", "annotation") ## rename annotations header to default name "annotation"
 
-    ## merge with coordinate information of MSI data
+    ## merge provided annotation with coordinate information of MSI data
     colnames(coordinates_info)[3] = "pixel_index"
     merged_annotation = merge(coordinates_info, annotation_input, by=c("x", "y"), all.x=TRUE)
     merged_annotation[is.na(merged_annotation)] = "NA"
+    ## order coordinate information according to pixel index to make sure that the order stays the same
     merged_annotation = merged_annotation[order(merged_annotation\$pixel_index),]
     samples = as.factor(merged_annotation\$annotation)
 
@@ -199,20 +212,28 @@
             maldi_data <- averageMassSpectra(maldi_data, labels=samples,method="mean") ## use average spectra for peak picking
             pixelnames = levels(samples)
             summarized_spectra = TRUE
-
+            random_spectra = sample(1:length(maldi_data), 4, replace=TRUE)
         #end if
 
         peaks <- detectPeaks(maldi_data, method="$method.methods_conditional.peak_method",
                   halfWindowSize=$method.methods_conditional.halfWindowSize,SNR=$method.methods_conditional.snr)
 
         ## QC plot and numbers
-        ## plot old spectrum with baseline in blue and picked peaks in green
-        noise = estimateNoise(maldi_data[[1]], method= "$method.methods_conditional.peak_method")
-        plot(maldi_data[[1]], main="First spectrum with noise line (blue) and picked peaks (green)")
-        lines(noise[,1], noise[,2]*$method.methods_conditional.snr, col="blue")
-        points(peaks[[1]], col="green", pch=20)
+        ## plot old spectra with baseline in blue and picked peaks in green
+        par(mfrow = c(2, 2), oma=c(0,0,2,0))
+        for (random_sample in random_spectra){
+            noise = estimateNoise(maldi_data[[random_sample]], method= "$method.methods_conditional.peak_method")
+            plot(maldi_data[[random_sample]], sub="", main=paste0("spectrum ", random_sample))
+            lines(noise[,1], noise[,2]*$method.methods_conditional.snr, col="blue")
+            points(peaks[[random_sample]], col="green", pch=20)}
+            title("S/N in blue and picked peaks in green", outer=TRUE, line=0)
+
         ## plot new spectrum
-        plot(peaks[[1]], main="First spectrum after peak detection")
+        par(mfrow = c(2, 2), oma=c(0,0,2,0))
+        for (random_sample in random_spectra){
+            plot(peaks[[random_sample]], sub="", main=paste0("spectrum ", random_sample))}
+        title("Picked peaks", outer=TRUE, line=0)
+
         pixel_number = length(peaks)
         minmz = round(min(unlist(lapply(peaks,mass))), digits=4)
         maxmz = round(max(unlist(lapply(peaks,mass))), digits=4)
@@ -242,14 +263,27 @@
         print('monoisotopic peaks')
         ##monoisotopic peaks
 
-        peaks = monoisotopicPeaks(peaks, minCor=$method.methods_conditional.minCor, tolerance=$method.methods_conditional.tolerance, distance=$method.methods_conditional.distance, size=$method.methods_conditional.size)
+        ## keep peaks to plot them with monoisotopic peaks
+        picked_peaks = peaks
 
-        ## QC plot and numbers
+        peaks = monoisotopicPeaks(peaks, minCor=$method.methods_conditional.minCor, 
+                tolerance=$method.methods_conditional.tolerance,
+                distance=$method.methods_conditional.distance, 
+                size=$method.methods_conditional.size)
+
         ## plot old spectrum with picked isotopes as green dots
-        plot(peaks[[1]], main="First spectrum with picked monoisotopic peaks (green)")
-        points(peaks[[1]], col="green", pch=20)
-        ## plot new spectrum
-        plot(peaks[[1]], main="First spectrum after monoisotopic peaks detection")
+        par(mfrow = c(2, 2), oma=c(0,0,2,0))
+        for (random_sample in random_spectra){
+            plot(picked_peaks[[random_sample]], sub="", main=paste0("spectrum ", random_sample))
+            points(peaks[[random_sample]], col="green", pch=20)}
+            title(paste0("Monoisotopic peaks in green"), outer=TRUE, line=0)
+
+
+        par(mfrow = c(2, 2), oma=c(0,0,2,0))
+        for (random_sample in random_spectra){
+            plot(peaks[[random_sample]], sub="", main=paste0("spectrum ", random_sample))}
+            title("Monoisotopic peaks", outer=TRUE, line=0)
+
         minmz = round(min(unlist(lapply(peaks,mass))), digits=4)
         maxmz = round(max(unlist(lapply(peaks,mass))), digits=4)
         mean_features = round(length(unlist(lapply(peaks,mass)))/length(peaks), digits=2)
@@ -273,6 +307,89 @@
             write.table(featureMatrix2, file="$intensity_matrix", quote = FALSE, row.names = TRUE, col.names=FALSE, sep = "\t")
         }else{print("There are no spectra with peaks left")}
 
+
+
+    #elif str( $method.methods_conditional.method ) == 'Align':
+
+        print('align')
+        ##align spectra with 2 separate functions
+
+
+        #if str($method.methods_conditional.reference_for_alignment.align_ref) == 'no_reference':
+            ## 1) calculate warping:
+                warping_function <- determineWarpingFunctions(peaks,
+                                      tolerance=$method.methods_conditional.tolerance, method="$method.methods_conditional.warping_method",
+                                      allowNoMatches=$method.methods_conditional.allow_nomatch, minFrequency = $method.methods_conditional.reference_for_alignment.min_frequency)
+            ## 2) warp spectra:
+                peaks = warpMassPeaks(peaks, warping_function, emptyNoMatches=$method.methods_conditional.empty_nomatch)
+
+
+        #elif str($method.methods_conditional.reference_for_alignment.align_ref) == 'yes_reference':
+
+            ## create reference mass_vector from tabular file
+            mass_vector = read.delim("$method.methods_conditional.reference_for_alignment.reference_file", header = $method.methods_conditional.reference_for_alignment.reference_header, stringsAsFactors = FALSE)[,$method.methods_conditional.reference_for_alignment.mz_column]
+            int_vector = rep(1,length(mass_vector))
+            mass_list = createMassPeaks(mass_vector, int_vector)
+
+            #if str($method.methods_conditional.reference_for_alignment.separate_alignment) == "FALSE"
+            print('default alignment')
+
+                ## 1) calculate warping:
+                    warping_function <- determineWarpingFunctions(peaks,
+                                          tolerance=$method.methods_conditional.tolerance, method="$method.methods_conditional.warping_method",
+                                          allowNoMatches=$method.methods_conditional.allow_nomatch, reference = mass_list)
+                ## 2) warp spectra:
+                    peaks = warpMassPeaks(peaks, warping_function, emptyNoMatches=$method.methods_conditional.empty_nomatch)
+
+            #elif str($method.methods_conditional.reference_for_alignment.separate_alignment) == "TRUE"
+            print('spectra wise alignment')
+
+                peaks_new_list =list()
+
+                for (pixelnb in 1:length(peaks))
+                {
+
+                    ## 1) calculate warping:
+                        warping_function <- determineWarpingFunctions(peaks[[pixelnb]],
+                                              tolerance=$method.methods_conditional.tolerance, method="$method.methods_conditional.warping_method",
+                                              allowNoMatches=$method.methods_conditional.allow_nomatch, reference = mass_list)
+                    ## 2) warp spectra:
+                        peaks_new_list = warpMassPeaks(list(peaks[[pixelnb]]), warping_function, emptyNoMatches=$method.methods_conditional.empty_nomatch)
+                }
+                peaks_new = peaks_new_list
+
+            #end if
+
+        #end if
+
+        ## QC plot and numbers
+        par(mfrow = c(2, 2), oma=c(0,0,2,0))
+        for (random_sample in random_spectra){
+            plot(peaks[[random_sample]], sub="", main=paste0("spectrum ", random_sample))}
+        title("Aligned spectra", outer=TRUE, line=0)
+        minmz = round(min(unlist(lapply(peaks,mass))), digits=4)
+        maxmz = round(max(unlist(lapply(peaks,mass))), digits=4)
+        mean_features = round(length(unlist(lapply(peaks,mass)))/length(peaks), digits=2)
+        medint = round(median(unlist(lapply(peaks,intensity))), digits=2)
+        number_features = length(unique(unlist(lapply(peaks,mass))))
+        aligned = c(minmz, maxmz,number_features,mean_features,  medint)
+        QC_numbers= cbind(QC_numbers, aligned)
+        vectorofactions = append(vectorofactions, "aligned")
+
+        if (length(peaks[!sapply(peaks, isEmpty)])>0){
+            featureMatrix <- intensityMatrix(peaks)
+            ## only for profile imzML file: featurematrix is overwritten:
+            #if $infile.ext == 'imzml'
+                #if str($centroids) == "FALSE"
+                    featureMatrix <- intensityMatrix(peaks, maldi_data)
+                #end if
+            #end if
+            featureMatrix2 =cbind(pixelnames, featureMatrix)
+            colnames(featureMatrix2)[1] = c("mz")
+            featureMatrix2 = t(featureMatrix2)
+            write.table(featureMatrix2, file="$intensity_matrix", quote = FALSE, row.names = TRUE, col.names=FALSE, sep = "\t")
+        }else{print("There are no spectra with peaks left")}
+
     #elif str( $method.methods_conditional.method ) == 'Binning':
 
         print('binning')
@@ -281,7 +398,10 @@
         peaks <- binPeaks(peaks, tolerance=$method.methods_conditional.bin_tolerance, method="$method.methods_conditional.bin_method")
 
         ## QC plot and numbers
-        plot(peaks[[1]], main="First spectrum after binning")
+        par(mfrow = c(2, 2), oma=c(0,0,2,0))
+        for (random_sample in random_spectra){
+            plot(peaks[[random_sample]], sub="", main=paste0("spectrum ", random_sample))}
+        title("Binned spectra", outer=TRUE, line=0)
         minmz = round(min(unlist(lapply(peaks,mass))), digits=4)
         maxmz = round(max(unlist(lapply(peaks,mass))), digits=4)
         mean_features = round(length(unlist(lapply(peaks,mass)))/length(peaks), digits=2)
@@ -329,7 +449,10 @@
         #end if
 
         ##QC plot and numbers
-        plot(peaks[[1]], main="First spectrum after m/z filtering")
+        par(mfrow = c(2, 2), oma=c(0,0,2,0))
+        for (random_sample in random_spectra){
+            plot(peaks[[random_sample]], sub="", main=paste0("spectrum ", random_sample))}
+        title("Filtered spectra", outer=TRUE, line=0)
         minmz = round(min(unlist(lapply(peaks,mass))), digits=4)
         maxmz = round(max(unlist(lapply(peaks,mass))), digits=4)
         mean_features = round(length(unlist(lapply(peaks,mass)))/length(peaks), digits=2)
@@ -368,7 +491,7 @@
 }else{print("There are no spectra with peaks left")}
 
 ## print table with QC values
-rownames(QC_numbers) = c("min m/z", "max mz", "# features", "median \n# features", "median\nintensity")
+rownames(QC_numbers) = c("min m/z", "max mz", "# features", "median \n# peaks (int.>0)", "median\nintensity")
 plot(0,type='n',axes=FALSE,ann=FALSE)
 grid.table(t(QC_numbers))
 
@@ -376,14 +499,14 @@
 
 if (summarized_spectra == FALSE){ 
     #if $infile.ext == 'imzml'
-        MALDIquantForeign::exportImzMl(peaks, file="out.imzMl", processed=$export_processed)
+        MALDIquantForeign::exportImzMl(peaks, file="out.imzMl", processed=TRUE)
     #elif $infile.ext == 'tabular'
         masspeaks_coordinates = matrix(unlist(strsplit(as.character(pixelnames), "\\_")), ncol=3, byrow=TRUE)
         ## extract x and y values and create the coordinate matrix in case tabular was input
         peaklist_coordinates = unique(cbind(as.numeric(masspeaks_coordinates[,2]), as.numeric(masspeaks_coordinates[,3])))
-        exportImzMl(peaks, file="out.imzMl", processed=$export_processed, coordinates=peaklist_coordinates)
+        exportImzMl(peaks, file="out.imzMl", processed=TRUE, coordinates=peaklist_coordinates)
     #elif $infile.ext == 'rdata'
-        MALDIquantForeign::exportImzMl(peaks, file="out.imzMl", processed=$export_processed, coordinates=cardinal_coordinates)
+        MALDIquantForeign::exportImzMl(peaks, file="out.imzMl", processed=TRUE, coordinates=cardinal_coordinates)
     #end if
 
 }
@@ -392,24 +515,26 @@
         </configfile>
     </configfiles>
     <inputs>
-        <param name="infile" type="data" format="imzml,tabular,rdata" label="Inputfile as imzML, peaklist or Cardinal MSImageSet saved as RData" help="imzML or tabular format (peak list) or Cardinal MSImageSet saved as RData"/>
-        <param name="centroids" type="boolean" label="Input data is centroided (picked)" help="Choose Yes if peak detection has already been done. Peak detection cannot be run again on centroided data" truevalue="TRUE" falsevalue="FALSE"/>
+        <param name="infile" type="data" format="imzml,tabular,rdata" label="MSI data" help="Input file as imzML (composite upload), tabular peaklist or Cardinal MSImageSet saved as RData (regular upload)"/>
+        <param name="centroids" type="boolean" label="Centroided input" help="Choose Yes if peak detection has already been done. Peak detection cannot be run again on centroided data" truevalue="TRUE" falsevalue="FALSE"/>
         <conditional name="restriction_conditional">
-            <param name="restriction" type="select" label="Read in only spectra of interest" help="This option only works for imzML files">
-                <option value="no_restriction" selected="True">Calculate on entire file</option>
-                <option value="restrict">Restrict to coordinates of interest</option>
+            <param name="restriction" type="select" label="Use only spectra of interest" help="This option only works for imzML files">
+                <option value="no_restriction" selected="True">No, calculate on entire file</option>
+                <option value="restrict">Yes, restrict to spectra of interest</option>
             </param>
             <when value="restrict">
-                <param name="coordinates_file" type="data" format="tabular" label="Tabular file with coordinates" help="x-values in first column, y-values in second column"/>
+                <param name="coordinates_file" type="data" format="tabular" label="Tabular file with coordinates"/>
+                <param name="column_x" data_ref="coordinates_file" label="Column with x values" type="data_column"/>
+                <param name="column_y" data_ref="coordinates_file" label="Column with y values" type="data_column"/>
                 <param name="coordinates_header" type="boolean" label="File contains a header line" truevalue="TRUE" falsevalue="FALSE"/>
             </when>
             <when value="no_restriction"/>
         </conditional>
 
         <conditional name="tabular_annotation">
-            <param name="load_annotation" type="select" label="Pixels have annotations" help="Annotations can be used during peak detection or filteringfsplit">
-                <option value="no_annotation" selected="True">pixels have no annotations</option>
-                <option value="yes_annotation">pixel annotation from file</option>
+            <param name="load_annotation" type="select" label="Spectra annotations" help="Annotations can be used for group wise peak detection or filtering">
+                <option value="no_annotation" selected="True">No</option>
+                <option value="yes_annotation">Yes</option>
             </param>
             <when value="yes_annotation">
                 <param name="annotation_file" type="data" format="tabular" label="Use annotations from tabular file"
@@ -426,6 +551,7 @@
                 <param name="method" type="select" label="Select a method">
                     <option value="Peak_detection">Peak detection</option>
                     <option value="monoisotopic_peaks">Keep only monoisotopic peaks</option>
+                    <option value="Align">Align Spectra (warping/phase correction)</option>
                     <option value="Binning">Binning</option>
                     <option value="Filtering">Filtering</option>
                 </param>
@@ -451,8 +577,42 @@
                     <param name="distance" type="float" label="Distance" value="1.00235" help="Distance between two consecutive peaks in an isotopic pattern. 1.00235 is average distance for polypeptides."/>
                     <param name="size" type="integer" label="Size" value="3" help="Size (length) of isotopic pattern, longer patterns are prefered over shorter ones, min size is 2."/>
                 </when>
+
+                <when value="Align">
+                    <param name="warping_method" type="select" label="Warping methods">
+                        <option value="lowess" selected="True">Lowess</option>
+                        <option value="linear">Linear</option>
+                        <option value="quadratic">Quadratic</option>
+                        <option value="cubic">Cubic</option>
+                    </param>
+                    <param name="tolerance" type="float" value="0.00005"
+                        label="Tolerance = abs(mz1 - mz2)/mz2"
+                        help="Maximal relative deviation of a peak position (m/z) to be considered as identical. For 50ppm use 0.00005 or 5e-5" />
+                    <param name="allow_nomatch" type="boolean" label="Don't throw an error when less than 2 reference m/z were found in a spectrum" truevalue="TRUE" falsevalue="FALSE"/>
+                    <param name="empty_nomatch" type="boolean" label="If TRUE the intensity values of MassSpectrum or MassPeaks objects with missing (NA) warping functions are set to zero" truevalue="TRUE" falsevalue="FALSE"/>
+                    <param name="remove_empty" type="boolean" label="Should empty spectra be removed" truevalue="TRUE" falsevalue="FALSE" help="For Cardinal RData files this step can only be performed if pixel annotations were provided"/>
+
+                    <conditional name="reference_for_alignment">
+                        <param name="align_ref" type="select" label="Reference" help="If given, samples will be aligned to reference, use internal calibrants to perform m/z calibration">
+                            <option value="no_reference" selected="True">no reference</option>
+                            <option value="yes_reference">reference from tabular file</option>
+                        </param>
+                        <when value="no_reference">
+                    <param name="min_frequency" type="float" value="0.9" label = "minFrequency" help="Removal of all peaks which occur in less than minFrequency spectra to generate the reference m/z"/>
+                        </when>
+                        <when value="yes_reference">
+                            <param name="reference_file" type="data" format="tabular"
+                                label="Reference m/z values"
+                                help="Tabular file"/>
+                            <param name="mz_column" data_ref="reference_file" label="Column with m/z values" type="data_column"/>
+                            <param name="reference_header" type="boolean" label="File contains a header line" truevalue="TRUE" falsevalue="FALSE"/>
+                            <param name="separate_alignment" type="boolean" label="Spectrum wise alignment" help="Internal binning is omitted to avoid interaction between spectra" truevalue="TRUE" falsevalue="FALSE"/>
+                        </when>
+                    </conditional>
+                </when>
+
                 <when value="Binning">
-                    <param name="bin_tolerance" type="float" value="0.002" label="Binning tolerance"
+                    <param name="bin_tolerance" type="float" value="0.002" label="Tolerance"
                         help="After the alignment the peak positions (mass) are very similar but not identical. The binning is needed to make similar peak mass values identical."/>
                     <param name="bin_method" display="radio" type="select" label="Bin creation rule" help="strict - creates bins never containing two or more peaks of the sampe sample. relaxed - allows multiple peaks of the same sample in one bin.">
                     <option value="strict" selected="True" >strict</option>
@@ -470,10 +630,9 @@
                 </when>
             </conditional>
         </repeat>
-        <param name="export_processed" type="boolean" label="Export file as processed imzML" help="otherwise continuous imzML will be exported" checked="True" truevalue="TRUE" falsevalue="FALSE"/>
     </inputs>
     <outputs>
-        <data format="imzml" name="outfile_imzml" label="${tool.name} on ${on_string}">
+        <data format="imzml" name="outfile_imzml" label="${tool.name} on ${on_string}: imzml">
             <!--filter>methods_conditional['method'] == 'Peak_detection'</filter-->
         </data>
         <data format="pdf" name="plots" from_work_dir="peaks_qc_plot.pdf" label = "${tool.name} on ${on_string}: QC"/>
@@ -519,6 +678,10 @@
             <output name="plots" file="peakdetection2_QC.pdf" compare="sim_size"/>
             <output name="masspeaks" file="masspeaks2.tabular"/>
             <output name="intensity_matrix" file="int2.tabular"/>
+            <output name="outfile_imzml" ftype="imzml" file="peak_detection2.imzml.txt" lines_diff="4">
+                <extra_files type="file" file="peak_detection2.imzml" name="imzml" lines_diff="6"/>
+                <extra_files type="file" file="peak_detection2.ibd" name="ibd" compare="sim_size"/>
+            </output>
         </test>
         <test>
             <param name="infile" value="" ftype="imzml">
@@ -559,6 +722,10 @@
             <output name="plots" file="peakdetection3_QC.pdf" compare="sim_size"/>
             <output name="intensity_matrix" file="intensity_matrix3.tabular"/>
             <output name="masspeaks" file="masspeaks3.tabular"/>
+            <output name="outfile_imzml" ftype="imzml" file="peak_detection3.imzml.txt" lines_diff="4">
+                <extra_files type="file" file="peak_detection3.imzml" name="imzml" lines_diff="6"/>
+                <extra_files type="file" file="peak_detection3.ibd" name="ibd" compare="sim_size"/>
+            </output>
         </test>
         <test>
             <param name="infile" value="testfile_squares.rdata" ftype="rdata"/>
@@ -569,6 +736,10 @@
             <output name="plots" file="peakdetection4_QC.pdf" compare="sim_size"/>
             <output name="intensity_matrix" file="intensity_matrix4.tabular"/>
             <output name="masspeaks" file="masspeaks4.tabular"/>
+            <output name="outfile_imzml" ftype="imzml" file="peak_detection4.imzml.txt" lines_diff="4">
+                <extra_files type="file" file="peak_detection4.imzml" name="imzml" lines_diff="6"/>
+                <extra_files type="file" file="peak_detection4.ibd" name="ibd" compare="sim_size"/>
+            </output>
         </test>
     </tests>
     <help>
@@ -596,7 +767,7 @@
             ...    
 
 
-- Optional:  Tabular file with pixel coordinates to restrict reading of imzML files to coordinates of interest. The file has to contain x values in the first column and y values in the second columns. Further columns are allowed. Tabular files with any header name or no header at all are supported. 
+- Optional:  Tabular file with pixel coordinates to restrict reading of imzML files to coordinates of interest. Tabular files with any header name or no header at all are supported. 
 
     ::
 
@@ -629,16 +800,21 @@
     - Detect peaks on average mass spectra: Spectra with the same annotation (taken from the annotation tabular input) are averaged and peak picking is performed on the average spectrum of each annotation group. The exported imzML is empty and cannot be used for further analysis steps. The peaklist and intensity matrix outputs contain the annotation group names with their averaged intensity values. Filtering steps have to be done in the same run as the peak picking.
 
 
-- Monoisotopic peaks: detection of monoisotopic peaks
+- Monoisotopic peaks: Keeps only the monoisotopic peaks
 
 
+- Spectra alignment (warping): alignment for (re)calibration of m/z values. 
+
+    - without external reference m/z: internal reference is obtained by filtering (default 90%) and binning the peaks to find landmark peaks and their average m/z
+    - with external reference m/z: the m/z provided in a tabular file are used as a reference, at least 10 reference values are recommended
+    - non linear warping (parametric time warping plus binning) to match the reference peaks (internal or external) to the peaks with the given tolerance. At least two m/z per spectrum are needed for the alignment. This requirement can be skipped by setting "Don't throw an error when less than 2 reference m/z were found in a spectrum" to yes. If the not aligned spectra should be set to zero select yes in "If TRUE the intensity values of MassSpectrum or MassPeaks objects with missing (NA) warping functions are set to zero". In order to remove such empty spectra set "Should empty spectra be removed" to yes. 
 
 
 - Peak binning: After the alignment the peak positions (m/z) are very similar but not identical. The binning is needed to make similar peak m/z values identical. The algorithm is based on the following workflow:
 
-    1. Put all mass in a sorted vector.
+    1. Put all m/z in a sorted vector.
     2. Calculate differences between each neighbor.
-    3. Divide the mass vector at the largest gap (largest difference) and form a left and a right bin.
+    3. Divide the m/z vector at the largest gap (largest difference) and form a left and a right bin.
     4. Rerun step 3 for the left and/or the right bin if they don't fulfill the following criteria:
 
     - All peaks in a bin are near to the mean (abs(mass-meanMass)/meanMass < tolerance).
@@ -655,8 +831,8 @@
 
 **Output**
 
-- centroided imzML file (processed or continuous), imzML file is empty when 'Detect peaks on average mass spectra' is chosen.
-- pdf with mass spectra plots after each preprocessing step and a table with key values after each preprocessing step
+- centroided, processed imzML file, imzML file is empty when 'Detect peaks on average mass spectra' is chosen.
+- pdf with mass spectra plots of four random spectra and a table with key values after each preprocessing step
 - peak list (tabular file) with the columns "snr", "mass", "intensity" and "spectrum"
 - tabular file with intensity matrix (m/z in rows and spectra in columns). If the input file was imzML in profile mode the intensities before peak picking are also stored in the matrix . For all other inputs not picked values are set to NA. For peak picking on the average of multiple spectra, each spectra group is a column with mean intensities for each m/z.
 
Binary file test-data/Preprocessing1_QC.pdf has changed
Binary file test-data/Preprocessing2_QC.pdf has changed
Binary file test-data/Preprocessing3_QC.pdf has changed
--- a/test-data/align_reference_test2.tabular	Thu Oct 25 07:32:17 2018 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-350
-340
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/inputpeptides.tabular	Fri Feb 15 10:26:45 2019 -0500
@@ -0,0 +1,3 @@
+152	mass1
+328.9	mass2
+185.2	mass3
Binary file test-data/outfile1.ibd has changed
--- a/test-data/outfile1.imzML	Thu Oct 25 07:32:17 2018 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-imzML file:
-total 84
--rw-r--r-- 1 meli meli 67160 Okt 24 10:12 ibd
--rw-r--r-- 1 meli meli 15071 Okt 24 10:12 imzml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/outfile1.imzml	Fri Feb 15 10:26:45 2019 -0500
@@ -0,0 +1,243 @@
+<?xml version="1.0" encoding="utf-8"?>
+<mzML xmlns="http://psi.hupo.org/ms/mzml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://psi.hupo.org/ms/mzml http://psidev.info/files/ms/mzML/xsd/mzML1.1.0.xsd" id="out" version="1.1.0">
+ <cvList count="2">
+  <cv id="MS" fullName="Proteomics Standards Initiative Mass Spectrometry Ontology" version="3.44.0" URI="http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo"/>
+  <cv id="UO" fullName="Unit Ontology" version="12:10:2012" URI="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/phenotype/unit.obo"/>
+  <cv id="IMS" fullName="Imaging MS Ontology" version="0.9.1" URI="http://www.maldi-msi.org/download/imzml/imagingMS.obo"/>
+ </cvList>
+ <fileDescription>
+  <fileContent>
+   <cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum"/>
+   <cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="{97729696-da30-4a3d-82ca-7f29db94e86d}"/>
+   <cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="c4e5c9a9a6557c53ec74a6d728093019ab2bbc41"/>
+   <cvParam cvRef="IMS" accession="IMS:1000030" name="continuous"/>
+   <userParam name="MALDIquantForeign" value="MALDIquant object(s) exported to mzML"/>
+  </fileContent>
+  <sourceFileList count="1">
+   <sourceFile id="SF1" location="/tmp/tmp08K9FY/job_working_directory/000/3/working" name="infile.imzML">
+    <cvParam cvRef="MS" accession="MS:1000569" name="SHA-1" value="0d2ad51f69d7b5df0f4d2b2a47b17478f2fca509"/>
+   </sourceFile>
+  </sourceFileList>
+ </fileDescription>
+ <softwareList count="1">
+  <software id="MALDIquantForeign" version="0.11.5"/>
+ </softwareList>
+ <referenceableParamGroupList count="2">
+  <referenceableParamGroup id="mzArray">
+   <cvParam cvRef="MS" accession="MS:1000514" name="m/z array" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+   <cvParam cvRef="MS" accession="MS:1000576" name="no compression" value=""/>
+   <cvParam cvRef="MS" accession="MS:1000523" name="64-bit float" value=""/>
+   <cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true"/>
+  </referenceableParamGroup>
+  <referenceableParamGroup id="intensityArray">
+   <cvParam cvRef="MS" accession="MS:1000515" name="intensity array" unitCvRef="MS" unitAccession="MS:1000131" unitName="number of counts"/>
+   <cvParam cvRef="MS" accession="MS:1000576" name="no compression" value=""/>
+   <cvParam cvRef="MS" accession="MS:1000523" name="64-bit float" value=""/>
+   <cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true"/>
+  </referenceableParamGroup>
+ </referenceableParamGroupList>
+ <scanSettingsList count="1">
+  <scanSettings id="scansetting1">
+   <cvParam cvRef="IMS" accession="IMS:1000042" name="max count of pixel x" value="3"/>
+   <cvParam cvRef="IMS" accession="IMS:1000043" name="max count of pixel y" value="3"/>
+   <cvParam cvRef="IMS" accession="IMS:1000044" name="max dimension x" value="300" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000045" name="max dimension y" value="300" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000046" name="pixel size x" value="100" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000047" name="pixel size y" value="100" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+  </scanSettings>
+ </scanSettingsList>
+ <instrumentConfigurationList count="1">
+  <instrumentConfiguration id="IC0"/>
+ </instrumentConfigurationList>
+ <dataProcessingList count="1">
+  <dataProcessing id="export">
+   <processingMethod order="1" softwareRef="MALDIquantForeign">
+    <userParam name="MALDIquant object(s) exported to mzML" value=""/>
+   </processingMethod>
+  </dataProcessing>
+ </dataProcessingList>
+ <run id="run0" defaultInstrumentConfigurationRef="IC0">
+  <spectrumList count="6" defaultDataProcessingRef="export">
+   <spectrum index="0" id="Spectrum=1" defaultArrayLength="1199">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="300.083343505859" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="399.916687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="2.44841884215683"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="9608"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="1" id="Spectrum=4" defaultArrayLength="1199">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="300.083343505859" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="399.916687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="4.72366236736229"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="19200"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="2" id="Spectrum=7" defaultArrayLength="1199">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="300.083343505859" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="399.916687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="2.34697718761883"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="28792"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="3" id="Spectrum=3" defaultArrayLength="1199">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="300.083343505859" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="399.916687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="3.39025471907476"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="38384"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="4" id="Spectrum=6" defaultArrayLength="1199">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="300.083343505859" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="399.916687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="1.5591991257541"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="47976"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="5" id="Spectrum=9" defaultArrayLength="1199">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="300.083343505859" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="399.916687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="4.31553230835188"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="57568"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+  </spectrumList>
+ </run>
+</mzML>
Binary file test-data/outfile2.ibd has changed
--- a/test-data/outfile2.imzML	Thu Oct 25 07:32:17 2018 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-imzML file:
-total 276
--rw-r--r-- 1 meli meli 268784 Okt 24 10:12 ibd
--rw-r--r-- 1 meli meli   9286 Okt 24 10:12 imzml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/outfile2.imzml	Fri Feb 15 10:26:45 2019 -0500
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="utf-8"?>
+<mzML xmlns="http://psi.hupo.org/ms/mzml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://psi.hupo.org/ms/mzml http://psidev.info/files/ms/mzML/xsd/mzML1.1.0.xsd" id="out" version="1.1.0">
+ <cvList count="2">
+  <cv id="MS" fullName="Proteomics Standards Initiative Mass Spectrometry Ontology" version="3.44.0" URI="http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo"/>
+  <cv id="UO" fullName="Unit Ontology" version="12:10:2012" URI="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/phenotype/unit.obo"/>
+  <cv id="IMS" fullName="Imaging MS Ontology" version="0.9.1" URI="http://www.maldi-msi.org/download/imzml/imagingMS.obo"/>
+ </cvList>
+ <fileDescription>
+  <fileContent>
+   <cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum"/>
+   <cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="{54a5519e-643b-4eb1-b82b-d55aaa5e9015}"/>
+   <cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="12d68eada8b274b1bba9520cef0ff98d6fc95bf4"/>
+   <cvParam cvRef="IMS" accession="IMS:1000030" name="continuous"/>
+   <userParam name="MALDIquantForeign" value="MALDIquant object(s) exported to mzML"/>
+  </fileContent>
+ </fileDescription>
+ <softwareList count="1">
+  <software id="MALDIquantForeign" version="0.11.5"/>
+ </softwareList>
+ <referenceableParamGroupList count="2">
+  <referenceableParamGroup id="mzArray">
+   <cvParam cvRef="MS" accession="MS:1000514" name="m/z array" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+   <cvParam cvRef="MS" accession="MS:1000576" name="no compression" value=""/>
+   <cvParam cvRef="MS" accession="MS:1000523" name="64-bit float" value=""/>
+   <cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true"/>
+  </referenceableParamGroup>
+  <referenceableParamGroup id="intensityArray">
+   <cvParam cvRef="MS" accession="MS:1000515" name="intensity array" unitCvRef="MS" unitAccession="MS:1000131" unitName="number of counts"/>
+   <cvParam cvRef="MS" accession="MS:1000576" name="no compression" value=""/>
+   <cvParam cvRef="MS" accession="MS:1000523" name="64-bit float" value=""/>
+   <cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true"/>
+  </referenceableParamGroup>
+ </referenceableParamGroupList>
+ <scanSettingsList count="1">
+  <scanSettings id="scansetting1">
+   <cvParam cvRef="IMS" accession="IMS:1000042" name="max count of pixel x" value="1"/>
+   <cvParam cvRef="IMS" accession="IMS:1000043" name="max count of pixel y" value="3"/>
+   <cvParam cvRef="IMS" accession="IMS:1000044" name="max dimension x" value="100" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000045" name="max dimension y" value="300" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000046" name="pixel size x" value="100" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000047" name="pixel size y" value="100" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+  </scanSettings>
+ </scanSettingsList>
+ <instrumentConfigurationList count="1">
+  <instrumentConfiguration id="IC0"/>
+ </instrumentConfigurationList>
+ <dataProcessingList count="1">
+  <dataProcessing id="export">
+   <processingMethod order="1" softwareRef="MALDIquantForeign">
+    <userParam name="MALDIquant object(s) exported to mzML" value=""/>
+   </processingMethod>
+  </dataProcessing>
+ </dataProcessingList>
+ <run id="run0" defaultInstrumentConfigurationRef="IC0">
+  <spectrumList count="2" defaultDataProcessingRef="export">
+   <spectrum index="0" id="scan=0" defaultArrayLength="8399">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="100.000007629395" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="799.816687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="16.7431673605698"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="8399"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="67192"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="67208"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="8399"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="67192"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="1" id="scan=1" defaultArrayLength="8399">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="100.083335876465" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="799.9" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="10.6534160746182"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="8399"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="67192"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="134400"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="8399"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="67192"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+  </spectrumList>
+ </run>
+</mzML>
Binary file test-data/outfile3.ibd has changed
--- a/test-data/outfile3.imzML	Thu Oct 25 07:32:17 2018 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-imzML file:
-total 52
--rw-r--r-- 1 meli meli 38384 Okt 24 10:13 ibd
--rw-r--r-- 1 meli meli  9551 Okt 24 10:13 imzml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/outfile3.imzml	Fri Feb 15 10:26:45 2019 -0500
@@ -0,0 +1,333 @@
+<?xml version="1.0" encoding="utf-8"?>
+<mzML xmlns="http://psi.hupo.org/ms/mzml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://psi.hupo.org/ms/mzml http://psidev.info/files/ms/mzML/xsd/mzML1.1.0.xsd" id="out" version="1.1.0">
+ <cvList count="2">
+  <cv id="MS" fullName="Proteomics Standards Initiative Mass Spectrometry Ontology" version="3.44.0" URI="http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo"/>
+  <cv id="UO" fullName="Unit Ontology" version="12:10:2012" URI="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/phenotype/unit.obo"/>
+  <cv id="IMS" fullName="Imaging MS Ontology" version="0.9.1" URI="http://www.maldi-msi.org/download/imzml/imagingMS.obo"/>
+ </cvList>
+ <fileDescription>
+  <fileContent>
+   <cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum"/>
+   <cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="{03b18aa8-8c35-4301-a8a0-2e4744557844}"/>
+   <cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="0419cfcec0eaebf56069d98ebfbde089c4ba0276"/>
+   <cvParam cvRef="IMS" accession="IMS:1000030" name="continuous"/>
+   <userParam name="MALDIquantForeign" value="MALDIquant object(s) exported to mzML"/>
+  </fileContent>
+  <sourceFileList count="1">
+   <sourceFile id="SF1" location="/tmp/tmp08K9FY/job_working_directory/000/8/working" name="infile.imzML">
+    <cvParam cvRef="MS" accession="MS:1000569" name="SHA-1" value="0d2ad51f69d7b5df0f4d2b2a47b17478f2fca509"/>
+   </sourceFile>
+  </sourceFileList>
+ </fileDescription>
+ <softwareList count="1">
+  <software id="MALDIquantForeign" version="0.11.5"/>
+ </softwareList>
+ <referenceableParamGroupList count="2">
+  <referenceableParamGroup id="mzArray">
+   <cvParam cvRef="MS" accession="MS:1000514" name="m/z array" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+   <cvParam cvRef="MS" accession="MS:1000576" name="no compression" value=""/>
+   <cvParam cvRef="MS" accession="MS:1000523" name="64-bit float" value=""/>
+   <cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true"/>
+  </referenceableParamGroup>
+  <referenceableParamGroup id="intensityArray">
+   <cvParam cvRef="MS" accession="MS:1000515" name="intensity array" unitCvRef="MS" unitAccession="MS:1000131" unitName="number of counts"/>
+   <cvParam cvRef="MS" accession="MS:1000576" name="no compression" value=""/>
+   <cvParam cvRef="MS" accession="MS:1000523" name="64-bit float" value=""/>
+   <cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true"/>
+  </referenceableParamGroup>
+ </referenceableParamGroupList>
+ <scanSettingsList count="1">
+  <scanSettings id="scansetting1">
+   <cvParam cvRef="IMS" accession="IMS:1000042" name="max count of pixel x" value="3"/>
+   <cvParam cvRef="IMS" accession="IMS:1000043" name="max count of pixel y" value="3"/>
+   <cvParam cvRef="IMS" accession="IMS:1000044" name="max dimension x" value="300" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000045" name="max dimension y" value="300" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000046" name="pixel size x" value="100" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000047" name="pixel size y" value="100" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+  </scanSettings>
+ </scanSettingsList>
+ <instrumentConfigurationList count="1">
+  <instrumentConfiguration id="IC0"/>
+ </instrumentConfigurationList>
+ <dataProcessingList count="1">
+  <dataProcessing id="export">
+   <processingMethod order="1" softwareRef="MALDIquantForeign">
+    <userParam name="MALDIquant object(s) exported to mzML" value=""/>
+   </processingMethod>
+  </dataProcessing>
+ </dataProcessingList>
+ <run id="run0" defaultInstrumentConfigurationRef="IC0">
+  <spectrumList count="9" defaultDataProcessingRef="export">
+   <spectrum index="0" id="Spectrum=1" defaultArrayLength="1199">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="300.083343505859" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="399.916687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="1.91003802923222"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="9608"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="1" id="Spectrum=2" defaultArrayLength="1199">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="300.083343505859" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="399.916687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="2.43854773252674"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="19200"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="2" id="Spectrum=3" defaultArrayLength="1199">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="300.083343505859" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="399.916687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="2.03600426721051"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="28792"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="3" id="Spectrum=4" defaultArrayLength="1199">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="300.083343505859" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="399.916687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="3.30179951067808"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="38384"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="4" id="Spectrum=5" defaultArrayLength="1199">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="300.083343505859" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="399.916687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="1.51742234085622"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="47976"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="5" id="Spectrum=6" defaultArrayLength="1199">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="300.083343505859" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="399.916687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="0.899428770536842"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="57568"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="6" id="Spectrum=7" defaultArrayLength="1199">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="300.083343505859" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="399.916687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="1.2235672802189"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="67160"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="7" id="Spectrum=8" defaultArrayLength="1199">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="300.083343505859" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="399.916687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="2.07217434338569"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="76752"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="8" id="Spectrum=9" defaultArrayLength="1199">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="300.083343505859" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="399.916687011719" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="2.93202744636375"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="86344"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="9592"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+  </spectrumList>
+ </run>
+</mzML>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/peak_detection1.imzml.txt	Fri Feb 15 10:26:45 2019 -0500
@@ -0,0 +1,4 @@
+imzML file:
+total 120
+-rw-r--r-- 1 meli meli 95936 Feb 14 17:46 ibd
+-rw-r--r-- 1 meli meli 20580 Feb 14 17:46 imzml
Binary file test-data/peak_detection2.ibd has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/peak_detection2.imzml	Fri Feb 15 10:26:45 2019 -0500
@@ -0,0 +1,319 @@
+<?xml version="1.0" encoding="utf-8"?>
+<mzML xmlns="http://psi.hupo.org/ms/mzml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://psi.hupo.org/ms/mzml http://psidev.info/files/ms/mzML/xsd/mzML1.1.0.xsd" id="out" version="1.1.0">
+ <cvList count="2">
+  <cv id="MS" fullName="Proteomics Standards Initiative Mass Spectrometry Ontology" version="3.44.0" URI="http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo"/>
+  <cv id="UO" fullName="Unit Ontology" version="12:10:2012" URI="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/phenotype/unit.obo"/>
+  <cv id="IMS" fullName="Imaging MS Ontology" version="0.9.1" URI="http://www.maldi-msi.org/download/imzml/imagingMS.obo"/>
+ </cvList>
+ <fileDescription>
+  <fileContent>
+   <cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum"/>
+   <cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="{cc20fc46-860b-42cc-91a3-69e42329f338}"/>
+   <cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="64664d4479a6efec0398b19c652ffa2688d95d92"/>
+   <cvParam cvRef="IMS" accession="IMS:1000031" name="processed"/>
+   <userParam name="MALDIquantForeign" value="MALDIquant object(s) exported to mzML"/>
+  </fileContent>
+ </fileDescription>
+ <softwareList count="1">
+  <software id="MALDIquantForeign" version="0.11.5"/>
+ </softwareList>
+ <referenceableParamGroupList count="2">
+  <referenceableParamGroup id="mzArray">
+   <cvParam cvRef="MS" accession="MS:1000514" name="m/z array" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+   <cvParam cvRef="MS" accession="MS:1000576" name="no compression" value=""/>
+   <cvParam cvRef="MS" accession="MS:1000523" name="64-bit float" value=""/>
+   <cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true"/>
+  </referenceableParamGroup>
+  <referenceableParamGroup id="intensityArray">
+   <cvParam cvRef="MS" accession="MS:1000515" name="intensity array" unitCvRef="MS" unitAccession="MS:1000131" unitName="number of counts"/>
+   <cvParam cvRef="MS" accession="MS:1000576" name="no compression" value=""/>
+   <cvParam cvRef="MS" accession="MS:1000523" name="64-bit float" value=""/>
+   <cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true"/>
+  </referenceableParamGroup>
+ </referenceableParamGroupList>
+ <scanSettingsList count="1">
+  <scanSettings id="scansetting1">
+   <cvParam cvRef="IMS" accession="IMS:1000042" name="max count of pixel x" value="3"/>
+   <cvParam cvRef="IMS" accession="IMS:1000043" name="max count of pixel y" value="3"/>
+   <cvParam cvRef="IMS" accession="IMS:1000044" name="max dimension x" value="300" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000045" name="max dimension y" value="300" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000046" name="pixel size x" value="100" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000047" name="pixel size y" value="100" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+  </scanSettings>
+ </scanSettingsList>
+ <instrumentConfigurationList count="1">
+  <instrumentConfiguration id="IC0"/>
+ </instrumentConfigurationList>
+ <dataProcessingList count="1">
+  <dataProcessing id="export">
+   <processingMethod order="1" softwareRef="MALDIquantForeign">
+    <userParam name="MALDIquant object(s) exported to mzML" value=""/>
+   </processingMethod>
+  </dataProcessing>
+ </dataProcessingList>
+ <run id="run0" defaultInstrumentConfigurationRef="IC0">
+  <spectrumList count="9" defaultDataProcessingRef="export">
+   <spectrum index="0" id="scan=0" defaultArrayLength="3">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="329.152786254883" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="367.645835876465" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="24"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="40"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="24"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="1" id="scan=1" defaultArrayLength="3">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="329.152786254883" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="366.562515258789" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="64"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="24"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="88"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="24"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="2" id="scan=2" defaultArrayLength="2">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="329.152786254883" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="366.562515258789" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="112"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="16"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="128"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="16"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="3" id="scan=3" defaultArrayLength="1">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="308.266668701172" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="308.266668701172" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="144"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="8"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="152"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="8"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="4" id="scan=4" defaultArrayLength="2">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="308.266668701172" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="329.697925567627" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="160"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="16"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="176"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="16"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="5" id="scan=5" defaultArrayLength="1">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="308.266668701172" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="308.266668701172" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="192"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="8"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="200"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="8"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="6" id="scan=6" defaultArrayLength="2">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="329.697925567627" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="387.850006103516" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="208"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="16"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="224"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="16"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="7" id="scan=7" defaultArrayLength="2">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="387.850006103516" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="394.791679382324" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="240"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="16"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="256"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="16"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="8" id="scan=8" defaultArrayLength="3">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="329.697925567627" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="394.791679382324" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="272"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="24"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="296"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="24"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+  </spectrumList>
+ </run>
+</mzML>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/peak_detection2.imzml.txt	Fri Feb 15 10:26:45 2019 -0500
@@ -0,0 +1,4 @@
+imzML file:
+total 24
+-rw-r--r-- 1 meli meli   320 Feb 14 18:44 ibd
+-rw-r--r-- 1 meli meli 19244 Feb 14 18:44 imzml
Binary file test-data/peak_detection3.ibd has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/peak_detection3.imzml	Fri Feb 15 10:26:45 2019 -0500
@@ -0,0 +1,324 @@
+<?xml version="1.0" encoding="utf-8"?>
+<mzML xmlns="http://psi.hupo.org/ms/mzml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://psi.hupo.org/ms/mzml http://psidev.info/files/ms/mzML/xsd/mzML1.1.0.xsd" id="out" version="1.1.0">
+ <cvList count="2">
+  <cv id="MS" fullName="Proteomics Standards Initiative Mass Spectrometry Ontology" version="3.44.0" URI="http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo"/>
+  <cv id="UO" fullName="Unit Ontology" version="12:10:2012" URI="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/phenotype/unit.obo"/>
+  <cv id="IMS" fullName="Imaging MS Ontology" version="0.9.1" URI="http://www.maldi-msi.org/download/imzml/imagingMS.obo"/>
+ </cvList>
+ <fileDescription>
+  <fileContent>
+   <cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum"/>
+   <cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="{00515efe-60d8-4171-bb57-6f33c159ef7d}"/>
+   <cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="59e17ebe18b0559646ba7a17e709054397f086ea"/>
+   <cvParam cvRef="IMS" accession="IMS:1000031" name="processed"/>
+   <userParam name="MALDIquantForeign" value="MALDIquant object(s) exported to mzML"/>
+  </fileContent>
+  <sourceFileList count="1">
+   <sourceFile id="SF1" location="/tmp/tmpPJKhfc/job_working_directory/000/8/working" name="infile.imzML">
+    <cvParam cvRef="MS" accession="MS:1000569" name="SHA-1" value="0d2ad51f69d7b5df0f4d2b2a47b17478f2fca509"/>
+   </sourceFile>
+  </sourceFileList>
+ </fileDescription>
+ <softwareList count="1">
+  <software id="MALDIquantForeign" version="0.11.5"/>
+ </softwareList>
+ <referenceableParamGroupList count="2">
+  <referenceableParamGroup id="mzArray">
+   <cvParam cvRef="MS" accession="MS:1000514" name="m/z array" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+   <cvParam cvRef="MS" accession="MS:1000576" name="no compression" value=""/>
+   <cvParam cvRef="MS" accession="MS:1000523" name="64-bit float" value=""/>
+   <cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true"/>
+  </referenceableParamGroup>
+  <referenceableParamGroup id="intensityArray">
+   <cvParam cvRef="MS" accession="MS:1000515" name="intensity array" unitCvRef="MS" unitAccession="MS:1000131" unitName="number of counts"/>
+   <cvParam cvRef="MS" accession="MS:1000576" name="no compression" value=""/>
+   <cvParam cvRef="MS" accession="MS:1000523" name="64-bit float" value=""/>
+   <cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true"/>
+  </referenceableParamGroup>
+ </referenceableParamGroupList>
+ <scanSettingsList count="1">
+  <scanSettings id="scansetting1">
+   <cvParam cvRef="IMS" accession="IMS:1000042" name="max count of pixel x" value="3"/>
+   <cvParam cvRef="IMS" accession="IMS:1000043" name="max count of pixel y" value="3"/>
+   <cvParam cvRef="IMS" accession="IMS:1000044" name="max dimension x" value="300" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000045" name="max dimension y" value="300" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000046" name="pixel size x" value="100" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000047" name="pixel size y" value="100" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+  </scanSettings>
+ </scanSettingsList>
+ <instrumentConfigurationList count="1">
+  <instrumentConfiguration id="IC0"/>
+ </instrumentConfigurationList>
+ <dataProcessingList count="1">
+  <dataProcessing id="export">
+   <processingMethod order="1" softwareRef="MALDIquantForeign">
+    <userParam name="MALDIquant object(s) exported to mzML" value=""/>
+   </processingMethod>
+  </dataProcessing>
+ </dataProcessingList>
+ <run id="run0" defaultInstrumentConfigurationRef="IC0">
+  <spectrumList count="9" defaultDataProcessingRef="export">
+   <spectrum index="0" id="Spectrum=1" defaultArrayLength="38">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="304.595254080636" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="370.523821149554" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="38"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="304"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="320"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="38"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="304"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="1" id="Spectrum=2" defaultArrayLength="33">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="306.32292175293" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="370.523821149554" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="624"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="33"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="264"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="888"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="33"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="264"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="2" id="Spectrum=3" defaultArrayLength="28">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="328.937515258789" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="396.916674804687" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="1152"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="28"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="224"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="1376"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="28"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="224"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="3" id="Spectrum=4" defaultArrayLength="38">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="304.595254080636" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="370.523821149554" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="1600"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="38"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="304"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="1904"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="38"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="304"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="4" id="Spectrum=5" defaultArrayLength="33">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="306.32292175293" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="370.523821149554" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="2208"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="33"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="264"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="2472"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="33"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="264"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="5" id="Spectrum=6" defaultArrayLength="28">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="328.937515258789" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="396.916674804687" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="2736"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="28"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="224"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="2960"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="28"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="224"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="6" id="Spectrum=7" defaultArrayLength="38">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="304.595254080636" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="370.523821149554" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="3184"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="38"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="304"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="3488"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="38"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="304"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="7" id="Spectrum=8" defaultArrayLength="33">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="306.32292175293" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="370.523821149554" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="3792"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="33"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="264"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="4056"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="33"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="264"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="8" id="Spectrum=9" defaultArrayLength="28">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="328.937515258789" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="396.916674804687" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="4320"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="28"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="224"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="4544"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="28"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="224"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+  </spectrumList>
+ </run>
+</mzML>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/peak_detection3.imzml.txt	Fri Feb 15 10:26:45 2019 -0500
@@ -0,0 +1,4 @@
+imzML file:
+total 28
+-rw-r--r-- 1 meli meli  4768 Feb 14 18:44 ibd
+-rw-r--r-- 1 meli meli 19627 Feb 14 18:44 imzml
Binary file test-data/peak_detection4.ibd has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/peak_detection4.imzml	Fri Feb 15 10:26:45 2019 -0500
@@ -0,0 +1,754 @@
+<?xml version="1.0" encoding="utf-8"?>
+<mzML xmlns="http://psi.hupo.org/ms/mzml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://psi.hupo.org/ms/mzml http://psidev.info/files/ms/mzML/xsd/mzML1.1.0.xsd" id="out" version="1.1.0">
+ <cvList count="2">
+  <cv id="MS" fullName="Proteomics Standards Initiative Mass Spectrometry Ontology" version="3.44.0" URI="http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo"/>
+  <cv id="UO" fullName="Unit Ontology" version="12:10:2012" URI="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/phenotype/unit.obo"/>
+  <cv id="IMS" fullName="Imaging MS Ontology" version="0.9.1" URI="http://www.maldi-msi.org/download/imzml/imagingMS.obo"/>
+ </cvList>
+ <fileDescription>
+  <fileContent>
+   <cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum"/>
+   <cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="{a9ea11c4-975e-4f4a-a174-906e8cf0bb77}"/>
+   <cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="7022792264dc3f66251f22bebb634de68cb6a9fc"/>
+   <cvParam cvRef="IMS" accession="IMS:1000031" name="processed"/>
+   <userParam name="MALDIquantForeign" value="MALDIquant object(s) exported to mzML"/>
+  </fileContent>
+ </fileDescription>
+ <softwareList count="1">
+  <software id="MALDIquantForeign" version="0.11.5"/>
+ </softwareList>
+ <referenceableParamGroupList count="2">
+  <referenceableParamGroup id="mzArray">
+   <cvParam cvRef="MS" accession="MS:1000514" name="m/z array" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+   <cvParam cvRef="MS" accession="MS:1000576" name="no compression" value=""/>
+   <cvParam cvRef="MS" accession="MS:1000523" name="64-bit float" value=""/>
+   <cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true"/>
+  </referenceableParamGroup>
+  <referenceableParamGroup id="intensityArray">
+   <cvParam cvRef="MS" accession="MS:1000515" name="intensity array" unitCvRef="MS" unitAccession="MS:1000131" unitName="number of counts"/>
+   <cvParam cvRef="MS" accession="MS:1000576" name="no compression" value=""/>
+   <cvParam cvRef="MS" accession="MS:1000523" name="64-bit float" value=""/>
+   <cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true"/>
+  </referenceableParamGroup>
+ </referenceableParamGroupList>
+ <scanSettingsList count="1">
+  <scanSettings id="scansetting1">
+   <cvParam cvRef="IMS" accession="IMS:1000042" name="max count of pixel x" value="13"/>
+   <cvParam cvRef="IMS" accession="IMS:1000043" name="max count of pixel y" value="3"/>
+   <cvParam cvRef="IMS" accession="IMS:1000044" name="max dimension x" value="1300" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000045" name="max dimension y" value="300" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000046" name="pixel size x" value="100" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+   <cvParam cvRef="IMS" accession="IMS:1000047" name="pixel size y" value="100" unitCvRef="UO" unitAccession="UO:0000017" unitName="micrometer"/>
+  </scanSettings>
+ </scanSettingsList>
+ <instrumentConfigurationList count="1">
+  <instrumentConfiguration id="IC0"/>
+ </instrumentConfigurationList>
+ <dataProcessingList count="1">
+  <dataProcessing id="export">
+   <processingMethod order="1" softwareRef="MALDIquantForeign">
+    <userParam name="MALDIquant object(s) exported to mzML" value=""/>
+   </processingMethod>
+  </dataProcessing>
+ </dataProcessingList>
+ <run id="run0" defaultInstrumentConfigurationRef="IC0">
+  <spectrumList count="24" defaultDataProcessingRef="export">
+   <spectrum index="0" id="scan=0" defaultArrayLength="90">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.470520019531" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.455810546875" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="90"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="720"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="736"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="90"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="720"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="1" id="scan=1" defaultArrayLength="70">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.434692382812" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.267028808594" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="1456"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="70"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="560"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="2016"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="70"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="560"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="2" id="scan=2" defaultArrayLength="89">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.434692382812" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.418090820312" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="2576"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="89"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="712"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="3288"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="89"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="712"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="3" id="scan=3" defaultArrayLength="89">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.434692382812" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.455810546875" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="4"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="4000"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="89"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="712"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="4712"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="89"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="712"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="4" id="scan=4" defaultArrayLength="75">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.434692382812" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.342529296875" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="5424"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="75"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="600"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="6024"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="75"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="600"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="5" id="scan=5" defaultArrayLength="84">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.434692382812" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.418090820312" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="6624"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="84"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="672"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="7296"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="84"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="672"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="6" id="scan=6" defaultArrayLength="82">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.434692382812" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.380310058594" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="7968"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="82"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="656"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="8624"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="82"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="656"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="7" id="scan=7" defaultArrayLength="89">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.434692382812" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.455810546875" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="4"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="9280"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="89"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="712"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="9992"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="89"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="712"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="8" id="scan=8" defaultArrayLength="88">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.434692382812" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.380310058594" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="1"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="10704"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="88"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="704"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="11408"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="88"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="704"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="9" id="scan=9" defaultArrayLength="73">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.470520019531" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.15380859375" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="2"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="12112"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="73"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="584"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="12696"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="73"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="584"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="10" id="scan=10" defaultArrayLength="86">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.434692382812" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="998.39892578125" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="3"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="13280"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="86"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="688"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="13968"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="86"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="688"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="11" id="scan=11" defaultArrayLength="96">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.398864746094" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.342529296875" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="4"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="14656"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="96"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="768"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="15424"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="96"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="768"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="12" id="scan=12" defaultArrayLength="76">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.398864746094" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.455810546875" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="10"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16192"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="76"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="608"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16800"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="76"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="608"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="13" id="scan=13" defaultArrayLength="71">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.398864746094" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.116027832031" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="11"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="17408"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="71"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="568"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="17976"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="71"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="568"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="14" id="scan=14" defaultArrayLength="65">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.434692382812" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.304809570312" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="12"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="18544"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="65"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="520"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="19064"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="65"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="520"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="15" id="scan=15" defaultArrayLength="65">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.434692382812" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.267028808594" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="13"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="1"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="19584"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="65"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="520"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="20104"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="65"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="520"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="16" id="scan=16" defaultArrayLength="72">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.434692382812" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="998.474365234375" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="10"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="20624"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="72"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="576"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="21200"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="72"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="576"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="17" id="scan=17" defaultArrayLength="71">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.398864746094" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.342529296875" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="11"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="21776"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="71"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="568"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="22344"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="71"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="568"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="18" id="scan=18" defaultArrayLength="73">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.398864746094" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="997.267150878906" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="12"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="22912"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="73"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="584"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="23496"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="73"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="584"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="19" id="scan=19" defaultArrayLength="77">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.398864746094" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.191528320312" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="13"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="2"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="24080"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="77"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="616"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="24696"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="77"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="616"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="20" id="scan=20" defaultArrayLength="72">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.398864746094" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.342529296875" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="10"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="25312"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="72"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="576"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="25888"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="72"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="576"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="21" id="scan=21" defaultArrayLength="65">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.398864746094" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.267028808594" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="11"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="26464"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="65"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="520"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="26984"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="65"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="520"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="22" id="scan=22" defaultArrayLength="78">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.398864746094" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.380310058594" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="12"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="27504"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="78"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="624"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="28128"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="78"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="624"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+   <spectrum index="23" id="scan=23" defaultArrayLength="65">
+    <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
+    <cvParam cvRef="MS" accession="MS:1000294" name="mass spectrum"/>
+    <cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="900.398864746094" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="999.304809570312" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+    <cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum"/>
+    <scanList count="1">
+     <scan>
+      <cvParam cvRef="IMS" accession="IMS:1000050" name="position x" value="13"/>
+      <cvParam cvRef="IMS" accession="IMS:1000051" name="position y" value="3"/>
+     </scan>
+    </scanList>
+    <binaryDataArrayList count="2">
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="mzArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="28752"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="65"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="520"/>
+      <binary/>
+     </binaryDataArray>
+     <binaryDataArray encodedLength="0">
+      <referenceableParamGroupRef ref="intensityArray"/>
+      <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="29272"/>
+      <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="65"/>
+      <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="520"/>
+      <binary/>
+     </binaryDataArray>
+    </binaryDataArrayList>
+   </spectrum>
+  </spectrumList>
+ </run>
+</mzML>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/peak_detection4.imzml.txt	Fri Feb 15 10:26:45 2019 -0500
@@ -0,0 +1,4 @@
+imzML file:
+total 80
+-rw-r--r-- 1 meli meli 29792 Feb 14 18:45 ibd
+-rw-r--r-- 1 meli meli 45290 Feb 14 18:45 imzml
Binary file test-data/peakdetection1_QC.pdf has changed
Binary file test-data/peakdetection2_QC.pdf has changed
Binary file test-data/peakdetection3_QC.pdf has changed
Binary file test-data/peakdetection4_QC.pdf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/preprocessing1.imzml.txt	Fri Feb 15 10:26:45 2019 -0500
@@ -0,0 +1,4 @@
+imzML file:
+total 84
+-rw-r--r-- 1 meli meli 67160 Feb 14 17:45 ibd
+-rw-r--r-- 1 meli meli 15071 Feb 14 17:45 imzml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/preprocessing2.imzml.txt	Fri Feb 15 10:26:45 2019 -0500
@@ -0,0 +1,4 @@
+imzML file:
+total 208
+-rw-r--r-- 1 meli meli 201592 Feb 14 17:45 ibd
+-rw-r--r-- 1 meli meli   7431 Feb 14 17:45 imzml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/preprocessing3.imzml.txt	Fri Feb 15 10:26:45 2019 -0500
@@ -0,0 +1,4 @@
+imzML file:
+total 120
+-rw-r--r-- 1 meli meli 95936 Feb 14 17:46 ibd
+-rw-r--r-- 1 meli meli 20580 Feb 14 17:46 imzml