changeset 3:71411ac28268 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:00 -0500
parents e754c2b545a9
children 60ee8c592b13
files maldi_macros.xml maldi_quant_preprocessing.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, 2829 insertions(+), 688 deletions(-) [+]
line wrap: on
line diff
--- a/maldi_macros.xml	Thu Oct 25 07:31:55 2018 -0400
+++ b/maldi_macros.xml	Fri Feb 15 10:26:00 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_preprocessing.xml	Thu Oct 25 07:31:55 2018 -0400
+++ b/maldi_quant_preprocessing.xml	Fri Feb 15 10:26:00 2019 -0500
@@ -1,671 +1,703 @@
-<tool id="maldi_quant_preprocessing" name="MALDIquant preprocessing" version="@VERSION@.2">
-    <description>
-        Preprocessing of mass-spectrometry imaging data
-    </description>
-    <macros>
-        <import>maldi_macros.xml</import>
-    </macros>
-    <expand macro="requirements"/>
-    <command detect_errors="exit_code">
-    <![CDATA[
-        cat '${maldi_quant_preprocessing}' &&
-        #if $infile.ext == 'imzml'
-            cp '${infile.extra_files_path}/imzml' infile.imzML &&
-            cp '${infile.extra_files_path}/ibd' infile.ibd &&
-        #elif $infile.ext == 'analyze75'
-            cp '${infile.extra_files_path}/hdr' infile.hdr &&
-            cp '${infile.extra_files_path}/img' infile.img &&
-            cp '${infile.extra_files_path}/t2m' infile.t2m &&
-            du infile.hdr &&
-            du infile.img &&
-            du -s -B1 infile.hdr &&
-        #else
-            ln -s $infile infile.RData &&
-        #end if
-        Rscript "${maldi_quant_preprocessing}" &&
-
-        mkdir $outfile_imzml.files_path &&
-        mv ./out.imzMl "${os.path.join($outfile_imzml.files_path, 'imzml')}" | true &&
-        mv ./out.ibd "${os.path.join($outfile_imzml.files_path, 'ibd')}" | true &&
-        echo "imzML file:" > $outfile_imzml &&
-        ls -l "$outfile_imzml.files_path" >> $outfile_imzml
-    ]]>
-    </command>
-    <configfiles>
-        <configfile name="maldi_quant_preprocessing"><![CDATA[
-
-@R_IMPORTS@
-
-#if $restriction_conditional.restriction == 'restrict':
-
-    print('Reading mask region')
-    ## Import imzML file
-
-    coordinate_matrix = as.matrix(read.delim("$restriction_conditional.coordinates_file", header = $restriction_conditional.coordinates_header, stringsAsFactors = FALSE))[,1:2]
-
-    maldi_data = importImzMl('infile.imzML',
-                     coordinates = coordinate_matrix)
-    pixelnames = paste0("x = ", coordinates(maldi_data)[,1],", y = ", coordinates(maldi_data)[,2])
-
-#else:
-
-    print('Reading entire file')
-    #if $infile.ext == 'imzml'
-        ## Import imzML file
-        maldi_data = import( 'infile.imzML', type="imzML" )
-        coordinates_info = cbind(coordinates(maldi_data)[,1:2], c(1:length(maldi_data)))
-    #elif $infile.ext == 'analyze75'
-        ## Import analyze7.5 file
-        maldi_data = importAnalyze( 'infile.hdr' )
-        coordinates_info = cbind(coordinates(maldi_data)[,1:2], c(1:length(maldi_data)))
-    #else
-        loadRData <- function(fileName){
-        #loads an RData file, and returns it
-        load(fileName)
-        get(ls()[ls() != "fileName"])
-        }
-        msidata = loadRData('infile.RData')
-        ## save coordinates
-        cardinal_coordinates = as.matrix(Cardinal::coord(msidata)[,1:2])
-        ## save mz values
-        cardinal_mzs = Cardinal::mz(msidata)
-        ## create MALDIquant MassSpectrum object
-        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)))
-        }
-
-    #end if
-
-#end if
-
-## Quality control plots during preprocessing
-
-pdf("prepro_qc_plot.pdf", fonts = "Times", pointsize = 12)
-plot(0,type='n',axes=FALSE,ann=FALSE)
-
-## if no filename is given, name of file in Galaxy history is used
-    #set $filename = $infile.display_name
-title(main=paste("$filename"))
-
-#if str($tabular_annotation.load_annotation) == 'yes_annotation':
-    print("use annotation file")
-
-    ## read and extract x,y,annotation information
-    input_tabular = read.delim("$tabular_annotation.annotation_file", header = $tabular_annotation.tabular_header, stringsAsFactors = FALSE)
-    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 (from above) 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"
-    merged_annotation = merged_annotation[order(merged_annotation\$pixel_index),]
-    samples = as.factor(merged_annotation\$annotation)
-
-## print annotation overview into PDF output
-
-        ## the more annotation groups a file has the smaller will be the legend
-        number_combined = length(levels(as.factor(merged_annotation\$annotation)))
-        if (number_combined<20){
-            legend_size = 10
-        }else if (number_combined>20 && number_combined<40){
-            legend_size = 9
-        }else if (number_combined>40 && number_combined<60){
-            legend_size = 8
-        }else if (number_combined>60 && number_combined<100){
-            legend_size = 7
-        }else{
-            legend_size = 6
-        }
-
-        combine_plot = ggplot(merged_annotation, aes(x=x, y=y, fill=annotation))+
-               geom_tile() +
-               coord_fixed()+
-               ggtitle("Spatial orientation of annotated data")+
-               theme_bw()+
-               theme(plot.title = element_text(hjust = 0.5))+
-               theme(text=element_text(family="ArialMT", face="bold", size=12))+
-               theme(legend.position="bottom",legend.direction="vertical")+
-               theme(legend.key.size = unit(0.2, "line"), legend.text = element_text(size = legend_size))+
-               guides(fill=guide_legend(ncol=5,byrow=TRUE))
-
-        print(combine_plot)
-
-#end if
-
-#################### Preprocessing methods #####################################
-
-## QC plot on input file
-avgSpectra = averageMassSpectra(maldi_data,method="mean")
-plot(avgSpectra, main="Average spectrum for input file")
-
-pixel_number = length(maldi_data)
-minmz = round(min(unlist(lapply(maldi_data,mass))), digits=4)
-maxmz = round(max(unlist(lapply(maldi_data,mass))), digits=4)
-mean_features = round(length(unlist(lapply(maldi_data,mass)))/length(maldi_data), digits=2)
-number_features = length(unique(unlist(lapply(maldi_data,mass))))
-medint = round(median(unlist(lapply(maldi_data,intensity))), digits=2)
-inputdata = c(minmz, maxmz,number_features,mean_features,  medint)
-QC_numbers= data.frame(inputdata = c(minmz, maxmz,number_features, mean_features, medint))
-vectorofactions = "inputdata"
-
-
-#for $method in $methods:
-
-    #if str( $method.methods_conditional.method ) == 'Transformation':
-
-        print('transforming')
-        ##transformation
-        maldi_data = transformIntensity(maldi_data, method="$method.methods_conditional.transform_method")
-        ## QC plot and numbers
-        avgSpectra = averageMassSpectra(maldi_data,method="mean")
-        plot(avgSpectra, main="Average spectrum after transformation")
-        pixel_number = length(maldi_data)
-        minmz = round(min(unlist(lapply(maldi_data,mass))), digits=4)
-        maxmz = round(max(unlist(lapply(maldi_data,mass))), digits=4)
-        mean_features = round(length(unlist(lapply(maldi_data,mass)))/length(maldi_data), digits=2)
-        medint = round(median(unlist(lapply(maldi_data,intensity))), digits=2)
-        number_features = length(unique(unlist(lapply(maldi_data,mass))))
-        transformed = c(minmz, maxmz,number_features,mean_features,  medint)
-        QC_numbers= cbind(QC_numbers, transformed)
-        vectorofactions = append(vectorofactions, "transformed")
-
-
-    #elif str( $method.methods_conditional.method ) == 'Smoothing':
-
-        print('smoothing')
-        ##smoothing
-
-        #if str($method.methods_conditional.methods_for_smoothing.smooth_method ) == 'SavitzkyGolay':
-        print('SavitzkyGolay')
-
-            maldi_data = smoothIntensity(maldi_data,
-                    method="SavitzkyGolay", polynomialOrder=$method.methods_conditional.methods_for_smoothing.polynomial,
-                    halfWindowSize=$method.methods_conditional.halfWindowSize)
-
-        #elif str($method.methods_conditional.methods_for_smoothing.smooth_method ) == 'MovingAverage':
-            print('MovingAverage')
-
-            maldi_data = smoothIntensity(maldi_data,
-                    method="MovingAverage", weighted=$method.methods_conditional.methods_for_smoothing.weighted,
-                    halfWindowSize=$method.methods_conditional.halfWindowSize)
-
-        #end if
-
-        ## QC plot and numbers
-        avgSpectra = averageMassSpectra(maldi_data,method="mean")
-        plot(avgSpectra, main="Average spectrum after smoothing", sub="")
-        pixel_number = length(maldi_data)
-        minmz = round(min(unlist(lapply(maldi_data,mass))), digits=4)
-        maxmz = round(max(unlist(lapply(maldi_data,mass))), digits=4)
-        mean_features = round(length(unlist(lapply(maldi_data,mass)))/length(maldi_data), digits=2)
-        medint = round(median(unlist(lapply(maldi_data,intensity))), digits=2)
-        number_features = length(unique(unlist(lapply(maldi_data,mass))))
-        smoothed = c(minmz, maxmz,number_features,mean_features,  medint)
-        QC_numbers= cbind(QC_numbers, smoothed)
-        vectorofactions = append(vectorofactions, "smoothed")
-
-
-    #elif str( $method.methods_conditional.method ) == 'Baseline':
-
-        print('baseline removing')
-        ## Remove baseline
-
-        #if str($method.methods_conditional.methods_for_baseline.baseline_method ) == 'SNIP':
-        print('SNIP')
-            random_spectra = sample(1:length(maldi_data), 4, replace=FALSE)
-            par(mfrow = c(2,2))
-            for (random_sample in random_spectra){
-                maldi_data_baseline = estimateBaseline(maldi_data[[random_sample]],
-                    method="SNIP", iterations=$method.methods_conditional.methods_for_baseline.iterations)
-                plot(maldi_data[[random_sample]], sub="", main=paste0("Estimated baseline for spectrum ", random_sample))
-                lines(maldi_data_baseline, col="blue", lwd=2)}
-
-            maldi_data = removeBaseline(maldi_data,
-                method="SNIP",
-                iterations=$method.methods_conditional.methods_for_baseline.iterations)
-
-        #elif str($method.methods_conditional.methods_for_baseline.baseline_method ) == 'TopHat':
-        print('TopHat')
-
-            maldi_data = removeBaseline(maldi_data,
-                method="TopHat",
-                halfWindowSize=$method.methods_conditional.methods_for_baseline.tophat_halfWindowSize)
-
-        #elif str($method.methods_conditional.methods_for_baseline.baseline_method ) == 'ConvexHull':
-        print('ConvexHull')
-
-            maldi_data = removeBaseline(maldi_data,
-                method="ConvecHull")
-
-        #elif str($method.methods_conditional.methods_for_baseline.baseline_method ) == 'median':
-        print('median')
-
-            maldi_data = removeBaseline(maldi_data,
-                method="TopHat",
-                halfWindowSize=$method.methods_conditional.methods_for_baseline.median_halfWindowSize)
-
-        #end if
-
-        ## QC plot and numbers
-        par(mfrow = c(1,1))
-        avgSpectra = averageMassSpectra(maldi_data,method="mean")
-        plot(avgSpectra, main="Average spectrum after baseline removal")
-        pixel_number = length(maldi_data)
-        minmz = round(min(unlist(lapply(maldi_data,mass))), digits=4)
-        maxmz = round(max(unlist(lapply(maldi_data,mass))), digits=4)
-        mean_features = round(length(unlist(lapply(maldi_data,mass)))/length(maldi_data), digits=2)
-        medint = round(median(unlist(lapply(maldi_data,intensity))), digits=2)
-        number_features = length(unique(unlist(lapply(maldi_data,mass))))
-        baseline_removed = c(minmz, maxmz,number_features,mean_features,  medint)
-        QC_numbers= cbind(QC_numbers, baseline_removed)
-        vectorofactions = append(vectorofactions, "baseline_removed")
-
-
-    #elif str( $method.methods_conditional.method ) == 'Calibrate':
-
-        print('calibrate')
-        ##calibrate
-
-        #if str($method.methods_conditional.cond_calibration_range) == "yes":
-            ## calibrate only given m/z range
-            maldi_data = calibrateIntensity(maldi_data,
-                method="$method.methods_conditional.calibrate_method",
-                range=c($method.methods_conditional.cond_calibration_range.mass_start, $method.methods_conditional.cond_calibration_range.mass_end))
-        #else:
-            maldi_data = calibrateIntensity(maldi_data,
-            method="$method.methods_conditional.calibrate_method")
-        #end if
-        ## QC plot and numbers
-        avgSpectra = averageMassSpectra(maldi_data,method="mean")
-        plot(avgSpectra, main="Average spectrum after normalization")
-        pixel_number = length(maldi_data)
-        minmz = round(min(unlist(lapply(maldi_data,mass))), digits=4)
-        maxmz = round(max(unlist(lapply(maldi_data,mass))), digits=4)
-        mean_features = round(length(unlist(lapply(maldi_data,mass)))/length(maldi_data), digits=2)
-        medint = round(median(unlist(lapply(maldi_data,intensity))), digits=2)
-        number_features = length(unique(unlist(lapply(maldi_data,mass))))
-        intensity_calibrated = c(minmz, maxmz,number_features,mean_features,  medint)
-        QC_numbers= cbind(QC_numbers, intensity_calibrated)
-        vectorofactions = append(vectorofactions, "intensity_calibrated ")
-
-
-    #elif str( $method.methods_conditional.method ) == 'Align':
-
-        print('align')
-        ##align spectra
-
-        #if str($method.methods_conditional.reference_for_alignment.align_ref) == 'no_reference':
-            maldi_data = alignSpectra(maldi_data, halfWindowSize=$method.methods_conditional.halfWindowSize,
-                SNR=$method.methods_conditional.snr, tolerance=$method.methods_conditional.tolerance,
-                allowNoMatches =$method.methods_conditional.allow_nomatch, emptyNoMatches = $method.methods_conditional.empty_nomatch,
-                warpingMethod="$method.methods_conditional.warping_method")
-
-        #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)[,1]
-            int_vector = rep(1,length(mass_vector))
-            mass_list = createMassPeaks(mass_vector, int_vector)
-
-            maldi_data = alignSpectra(maldi_data, halfWindowSize=$method.methods_conditional.halfWindowSize,
-                SNR=$method.methods_conditional.snr,
-                tolerance=$method.methods_conditional.tolerance,
-                warpingMethod="$method.methods_conditional.warping_method", 
-                reference = mass_list, allowNoMatches =$method.methods_conditional.allow_nomatch, emptyNoMatches = $method.methods_conditional.empty_nomatch)
-
-        #end if
-
-        #if $method.methods_conditional.remove_empty:
-            print("remove empty spectra")
-
-            #if $infile.ext == 'rdata'
-                cardinal_coordinates = cardinal_coordinates[-findEmptyMassObjects(maldi_data),] ## remove coordinates of empty spectra for Cardinal RData input
-            #end if
-            #if str($tabular_annotation.load_annotation) == 'yes_annotation':
-                merged_annotation = merged_annotation[-findEmptyMassObjects(maldi_data),] ## remove coordinate annotations for empty spectra
-            #end if
-            maldi_data = removeEmptyMassObjects(maldi_data)
-        #end if
-
-
-        ## QC plot
-
-        if (length(maldi_data)>0){
-            avgSpectra = averageMassSpectra(maldi_data,method="mean")
-            plot(avgSpectra, main="Average spectrum after alignment")
-        }else{"All spectra are empty"}
-
-        pixel_number = length(maldi_data)
-        minmz = round(min(unlist(lapply(maldi_data,mass))), digits=4)
-        maxmz = round(max(unlist(lapply(maldi_data,mass))), digits=4)
-        mean_features = round(length(unlist(lapply(maldi_data,mass)))/length(maldi_data), digits=2)
-        medint = round(median(unlist(lapply(maldi_data,intensity))), digits=2)
-        number_features = length(unique(unlist(lapply(maldi_data,mass))))
-        spectra_aligned = c(minmz, maxmz,number_features,mean_features, medint)
-        QC_numbers= cbind(QC_numbers, spectra_aligned)
-        vectorofactions = append(vectorofactions, "spectra_aligned")
-    #end if
-
-#end for
-
-rownames(QC_numbers) = c("min m/z", "max mz", "# features", "median \n# features", "median\nintensity")
-plot(0,type='n',axes=FALSE,ann=FALSE)
-grid.table(t(QC_numbers))
-
-dev.off()
-
-## export imzML file
-if (length(maldi_data)>0){
-    #if $infile.ext == 'rdata'
-        MALDIquantForeign::exportImzMl(maldi_data, file="out.imzMl", processed=$export_processed, coordinates=cardinal_coordinates)
-    #else
-        MALDIquantForeign::exportImzMl(maldi_data, file="out.imzMl", processed=$export_processed)
-    #end if
-
-}else{"All spectra are empty, outputfiles will be empty,too."}
-
-    ]]>
-        </configfile>
-    </configfiles>
-    <inputs>
-        <param name="infile" type="data" format="imzml,rdata,analyze75" label="Inputfile as imzML or Cardinal MSImageSet saved as RData" help="This file is in imzML format or Cardinal MSImageSet saved as RData. The file must be in profile mode, not centroided"/>
-        <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>
-            <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_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="For Cardinal RData only: Use pixel annotation from tabular file to have updated annotation information in case empty spectra will be removed">
-                <option value="no_annotation" selected="True">use no annotation</option>
-                <option value="yes_annotation">use pixel annotation from a tabular file</option>
-            </param>
-                <when value="yes_annotation">
-                    <param name="annotation_file" type="data" format="tabular" label="Use annotations from tabular file"
-                    help="Tabular file with three columns: x values, y values and pixel annotations"/>
-                        <param name="column_x" data_ref="annotation_file" label="Column with x values" type="data_column"/>
-                        <param name="column_y" data_ref="annotation_file" label="Column with y values" type="data_column"/>
-                        <param name="column_names" data_ref="annotation_file" label="Column with pixel annotations" type="data_column"/>
-                        <param name="tabular_header" type="boolean" label="File contains a header line" truevalue="TRUE" falsevalue="FALSE"/>
-                </when>
-                <when value="no_annotation"/>
-        </conditional>
-        <repeat name="methods" title="Method" min="1">
-            <conditional name="methods_conditional">
-                <param name="method" type="select" label="Select a method">
-                    <option value="Transformation" selected="True">Transformation</option>
-                    <option value="Smoothing">Smoothing</option>
-                    <option value="Baseline">Baseline removal</option>
-                    <option value="Calibrate">Calibrate</option>
-                    <option value="Align">Align Spectra (warping/phase correction)</option>
-                    <validator type="empty_field" />
-                </param>
-                <when value="Transformation">
-                    <param name="transform_method" type="select" label="Select a transfprormation method">
-                        <option value="sqrt" selected="True">sqrt</option>
-                        <option value="log">log</option>
-                        <option value="log2">log2</option>
-                        <option value="log10">log10</option>
-                        <validator type="empty_field" />
-                    </param>
-                </when>
-                <when value="Smoothing">
-                    <conditional name="methods_for_smoothing">
-                        <param name="smooth_method" type="select" label="This method smoothes the intensity values of a MassSpectrum object">
-                            <option value="SavitzkyGolay" selected="True">SavitzkyGolay</option>
-                            <option value="MovingAverage">MovingAverage</option>
-                        </param>
-                        <when value="SavitzkyGolay">
-                            <param name="polynomial" value="3" type="text" label="PolynomialOrder argument to control the order of the filter"
-                                    help="should be smaller than the resulting window"/>
-                        </when>
-                        <when value="MovingAverage">
-                            <param name="weighted" type="boolean" label="Weighted average" help = "Indicates if the average should be equal weight or if it should have weights depending on the distance from the center as calculated as 1/2^abs(-halfWindowSize:halfWindowSize) with the sum of all weigths normalized to 1" truevalue="TRUE" falsevalue="FALSE"/>
-                        </when>
-                    </conditional>
-                    <param name="halfWindowSize" type="integer" value="10"
-                        label="Half window size (number of data points)"
-                        help="The resulting window reaches from 
-                            mass[currentIndex-halfWindowSize] to mass[currentIndex+halfWindowSize]
-                            (window size is 2*halfWindowSize+1)."/>
-                </when>
-                <when value="Baseline">
-                    <conditional name="methods_for_baseline">
-                        <param name="baseline_method" type="select" label="Baseline removal method">
-                            <option value="SNIP" selected="True">SNIP</option>
-                            <option value="TopHat">TopHat</option>
-                            <option value="ConvexHull">ConvexHull</option>
-                            <option value="median">median</option>
-                            <validator type="empty_field" />
-                        </param>
-                        <when value="SNIP">
-                            <param name="iterations" type="integer" value="100"
-                        label="Number of iterations" help="Corresponds to half window size: The resulting window reaches from mass[cur_index-iterations] to mass[cur_index+iterations]"/>
-                        </when>
-                        <when value="TopHat">
-                            <param name="tophat_halfWindowSize" type="integer" value="10"
-                        label="Half window size (number of data points)"
-                            help="The resulting window reaches from 
-                            mass[currentIndex-halfWindowSize] to mass[currentIndex+halfWindowSize]"/>
-                        </when>
-                        <when value="ConvexHull"/>
-                        <when value="median">
-                            <param name="median_halfWindowSize" type="integer" value="10"
-                        label="Half window size (number of data points)"
-                            help="The resulting window reaches from 
-                            mass[currentIndex-halfWindowSize] to mass[currentIndex+halfWindowSize]"/>
-                        </when>
-                    </conditional>
-                </when>
-                <when value="Calibrate">
-                    <param name="calibrate_method" type="select" label="Intensity calibration (normalization) method">
-                        <option value="TIC" selected="True">TIC</option>
-                        <option value="PQN">PQN</option>
-                        <option value="median">median</option>
-                        <validator type="empty_field" />
-                    </param>
-                    <conditional name="cond_calibration_range">
-                        <param name="calibration_range" type="select" label="Instead of the whole m/z range, a specified m/z range can be used to calculate the scaling factor">
-                            <option value="no" selected="True">complete m/z range</option>
-                            <option value="yes">specify a m/z range</option>
-                        </param>
-                        <when value="no"/>
-                        <when value="yes">
-                            <param name="mass_start" type="integer" value="800"
-                                label="Start of m/z range, has to be inside m/z range" 
-                                help="Scaling factor is calculated on the mass range and applied to the whole spectrum."/>
-                            <param name="mass_end" type="integer" value="3000"
-                                label="End of m/z range, has to be inside m/z range"/>
-                        </when>
-                    </conditional>
-                </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 50e-6" />
-
-                    <param name="halfWindowSize" type="integer" value="20"
-                        label="Half window size (number of data points)"
-                        help="The resulting window reaches from 
-                            mass[currentIndex-halfWindowSize] to mass[currentIndex+halfWindowSize]
-                            (window size is 2*halfWindowSize+1).
-                            The best size differs depending on the selected smoothing method."/>
-
-                    <param name="snr" type="integer" value="2" label="Signal-to-noise-ratio"/>
-                    <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 to which the samples should be aligned" help="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"/>
-                        <when value="yes_reference">
-                            <param name="reference_file" type="data" format="tabular"
-                                label="Tabular file with m/z (MassPeaks) which should be used for spectra alignment"
-                                help="At least 2 reference m/z per spectrum are needed"/>
-                            <param name="reference_header" type="boolean" label="File contains a header line" truevalue="TRUE" falsevalue="FALSE"/>
-                        </when>
-                    </conditional>
-                </when>
-            </conditional>
-        </repeat>
-        <param name="export_processed" type="boolean" label="Export file as processed imzML" help="otherwise continuous imzML will be exported" truevalue="TRUE" falsevalue="FALSE"/>
-    </inputs>
-    <outputs>
-        <data format="imzml" name="outfile_imzml" label="${tool.name} on ${on_string}" />
-        <data format="pdf" name="plots" from_work_dir="prepro_qc_plot.pdf" label="${tool.name} on ${on_string}: QC"/>
-    </outputs>
-    <tests>
-        <test>
-            <param name="infile" value="" ftype="imzml">
-                <composite_data value="Example_Continuous.imzML"/>
-                <composite_data value="Example_Continuous.ibd"/>
-            </param>
-            <conditional name="restriction_conditional">
-                <param name="restriction" value="restrict"/>
-                <param name="coordinates_file" value="restricted_pixels.tabular"/>
-            </conditional>
-            <conditional name="methods_conditional">
-                <param name="method" value="Transformation"/>
-                <param name="transform_method" value="log2"/>
-                <param name="method" value="Smoothing"/>
-                <param name="smooth_method" value="SavitzkyGolay"/>
-                <param name="method" value="Basline"/>
-                <param name="baseline_method" value ="TopHat"/>
-            </conditional>
-            <output name="outfile_imzml" file="outfile1.imzML" compare="sim_size"/>
-            <output name="outfile_imzml" file="outfile1.ibd" compare="sim_size"/>
-            <output name="plots" file="Preprocessing1_QC.pdf" compare="sim_size"/>
-        </test>
-        <test>
-            <param name="infile" value="msidata_1.RData" ftype="rdata"/>
-            <conditional name="methods_conditional">
-                <param name="method" value="Calibrate"/>
-                <param name="calibrate_method" value="PQN"/>
-            </conditional>
-            <output name="outfile_imzml" file="outfile2.imzML" compare="sim_size"/>
-            <output name="outfile_imzml" file="outfile2.ibd" compare="sim_size"/>
-            <output name="plots" file="Preprocessing2_QC.pdf" compare="sim_size"/>
-        </test>
-        <test>
-            <param name="infile" value="" ftype="imzml">
-                <composite_data value="Example_Continuous.imzML"/>
-                <composite_data value="Example_Continuous.ibd"/>
-            </param>
-            <conditional name="tabular_annotation">
-                <param name="load_annotation" value="yes_annotation"/>
-                <param name="annotation_file" value="pixel_annotations.tabular"/>
-                <param name="column_x" value="1"/>
-                <param name="column_y" value="2"/>
-                <param name="column_names" value="3"/>
-                <param name="tabular_header" value="TRUE"/>
-            </conditional>
-            <conditional name="methods_conditional">
-                <param name="method" value="Align"/>
-                <param name="warping_method" value="linear"/>
-                <param name="halfWindowSize" value="1"/>
-                <param name="tolerance" value="0.002"/>
-                <param name="allow_nomatch" value="TRUE"/>
-                <param name="remove_empty" value="TRUE"/>
-                <param name="empty_nomatch" value="TRUE"/>
-                <conditional name="reference_for_alignment">
-                    <param name="align_ref" value="yes_reference"/>
-                    <param name="reference_file" value="align_reference_test2.tabular" ftype="tabular"/>
-                </conditional>
-            </conditional>
-            <output name="outfile_imzml" file="outfile3.imzML" compare="sim_size"/>
-            <output name="outfile_imzml" file="outfile3.ibd" compare="sim_size"/>
-            <output name="plots" file="Preprocessing3_QC.pdf" compare="sim_size"/>
-        </test>
-    </tests>
-    <help><![CDATA[
-
-@MADLI_QUANT_DESCRIPTION@
-
------
-
-**Input data**
-
-- MSI data: 2 types of input data can be used:
-
-    - imzml file (upload imzml and ibd file via the "composite" function) `Introduction to the imzml format <https://ms-imaging.org/wp/imzml/>`_
-    - Cardinal "MSImageSet" data saved as .RData
-- Only for Cardinal RData files and when remove empty spectra is chosen: Tabular file with coordinates annotations. Separate columns for x and y coordinates and a third column with pixel annotations. 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. 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. 
-
-    ::
-
-       x_coord     y_coord 
-         1            1    
-         2            1    
-         3            1    
-        ...
-        ...
-
-- Optional: Tabular file with reference m/z for the spectra align function. At least 2 m/z values of the input list must be present in every spectrum to peform the alignment. First column must contain m/z values, without empty fields or letters. Tabular files with any header name or no header at all are supported. 
-
-    ::
-
-    
-            m/z
-          100.0
-          100.01
-          100.02
-        ...
-        ...    
-
-
-
-**Options**
-
-- Transformation: Variance stabilization through intensity transformation:'log', 'log2', 'log10' and 'squareroot' (sqrt) are available
-- Smoothing: Smoothing of the peaks reduces noise and improves peak detection. Available smoothing methods are 'SavitzkyGolay' and 'Moving Average'
-
-    - For all smoothing methods: The larger the 'Half window size'f, the stronger the smoothing. The resulting window should be smaller than the FWHM (full width at half maximum) of the typical peaks. Moving average needs smaller window size than SavitzkyGolay.
-    - Moving average: Recommended for broader peaks/high m/z range spectra. Weighted moving average: Points in the center get larger weight factors than points away from the center.  
-    - SavitzkyGolay: Recommended for sharp peaks/low m/z range, preserves the shape of the local maxima. The PolynomialOrder should be smaller than the resulting window. Negative values will be replaced with 0. 
-
-- Baseline reduction: Baseline reduction removes background intensity generated by chemical noise (common in MALDI datasets). 
-
-    - Available methods are SNIP, TopHat,ConvexHull and median:
-    - SNIP is the default baseline reduction method in MALDIquant. 
-    - ConvexHull is not appropriate for MALDI-TOF baseline removal. 
-    - The moving median may generate negative intensities. 
-    - Except for the ConvexHull all methods have a parameter for the 'Half window size' (in SNIP it is called 'iterations'). The smaller the window the more baseline will be removed but also parts of the peaks. Wider windows preserve the peak height better and produce a smoother baseline, but some local background variation will remain. 
-
-- Intensity calibration (normalization): Normalization of intensities to Total Ion Current (TIC), median spectrum, Probabilistic Quotient Normalization (PQN)
-
-    - TIC and median are local calibration methods: each spectrum is normalized on its own (each peak is divided by the TIC or median of the spectrum)
-    - PQN is a global calibration method: In PQN all spectra are calibrated using the TIC calibration first. Subsequently, a median reference spectrum is created and the intensities in all spectra are standardized using the reference spectrum and a spectrum-specific median is calculated for each spectrum. Finally, each spectrum is rescaled by the median of the ratios of its intensity values and that of the reference spectrum
-
-- Spectra alignment (warping): alignment for (re)calibration of m/z values, 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 "logical, 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. 
-
-
-**Output**
-
-- imzML file (imzML format can be continuous or processed)
-- PDF with average mass spectra after each preprocessing step
-
-.. _MALDIquant: http://strimmerlab.org/software/maldiquant/
-
-        ]]>
-    </help>
-    <expand macro="citation"/>
-</tool>
+<tool id="maldi_quant_preprocessing" name="MALDIquant preprocessing" version="@VERSION@.3">
+    <description>
+        Preprocessing of mass-spectrometry imaging data
+    </description>
+    <macros>
+        <import>maldi_macros.xml</import>
+    </macros>
+    <expand macro="requirements"/>
+    <command detect_errors="exit_code">
+    <![CDATA[
+        cat '${maldi_quant_preprocessing}' &&
+        #if $infile.ext == 'imzml'
+            cp '${infile.extra_files_path}/imzml' infile.imzML &&
+            cp '${infile.extra_files_path}/ibd' infile.ibd &&
+        #elif $infile.ext == 'analyze75'
+            cp '${infile.extra_files_path}/hdr' infile.hdr &&
+            cp '${infile.extra_files_path}/img' infile.img &&
+            cp '${infile.extra_files_path}/t2m' infile.t2m &&
+            du infile.hdr &&
+            du infile.img &&
+            du -s -B1 infile.hdr &&
+        #else
+            ln -s $infile infile.RData &&
+        #end if
+        Rscript "${maldi_quant_preprocessing}" &&
+
+        mkdir $outfile_imzml.files_path &&
+        mv ./out.imzMl "${os.path.join($outfile_imzml.files_path, 'imzml')}" | true &&
+        mv ./out.ibd "${os.path.join($outfile_imzml.files_path, 'ibd')}" | true &&
+        echo "imzML file:" > $outfile_imzml &&
+        ls -l "$outfile_imzml.files_path" >> $outfile_imzml
+    ]]>
+    </command>
+    <configfiles>
+        <configfile name="maldi_quant_preprocessing"><![CDATA[
+
+@R_IMPORTS@
+
+#if $restriction_conditional.restriction == 'restrict':
+
+    print('Reading mask region')
+    ## 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)
+    pixelnames = paste0("x = ", coordinates(maldi_data)[,1],", y = ", coordinates(maldi_data)[,2])
+
+#else:
+
+    print('Reading entire file')
+    #if $infile.ext == 'imzml'
+        ## Import imzML file
+        maldi_data = import( 'infile.imzML', type="imzML" )
+        coordinates_info = cbind(coordinates(maldi_data)[,1:2], c(1:length(maldi_data)))
+    #elif $infile.ext == 'analyze75'
+        ## Import analyze7.5 file
+        maldi_data = importAnalyze( 'infile.hdr' )
+        coordinates_info = cbind(coordinates(maldi_data)[,1:2], c(1:length(maldi_data)))
+    #else
+        loadRData <- function(fileName){
+        ##loads an RData file, and returns it
+        load(fileName)
+        get(ls()[ls() != "fileName"])
+        }
+        msidata = loadRData('infile.RData')
+        ## save coordinates
+        cardinal_coordinates = as.matrix(Cardinal::coord(msidata)[,1:2])
+        ## save mz values
+        cardinal_mzs = Cardinal::mz(msidata)
+        ## create MALDIquant MassSpectrum object, order of pixels in iData is same as in coord(msidata):
+        maldi_data = list()
+        for(number_spectra in 1:ncol(msidata)){
+        maldi_data[[number_spectra]] = MALDIquant::createMassSpectrum(mass = cardinal_mzs, intensity = iData(msidata)[,number_spectra])
+        }
+    #end if
+
+#end if
+
+## Quality control plots during preprocessing
+
+pdf("prepro_qc_plot.pdf", fonts = "Times", pointsize = 12)
+plot(0,type='n',axes=FALSE,ann=FALSE)
+
+## if no filename is given, name of file in Galaxy history is used
+    #set $filename = $infile.display_name
+title(main=paste("$filename"))
+
+
+#################### Preprocessing methods #####################################
+
+## QC plot on input file
+avgSpectra = averageMassSpectra(maldi_data,method="mean")
+plot(avgSpectra, main="Average spectrum for input file")
+
+pixel_number = length(maldi_data)
+minmz = round(min(unlist(lapply(maldi_data,mass))), digits=4)
+maxmz = round(max(unlist(lapply(maldi_data,mass))), digits=4)
+mean_features = round(length(unlist(lapply(maldi_data,mass)))/length(maldi_data), digits=2)
+number_features = length(unique(unlist(lapply(maldi_data,mass))))
+medint = round(median(unlist(lapply(maldi_data,intensity))), digits=2)
+inputdata = c(minmz, maxmz,number_features,mean_features,medint, pixel_number)
+QC_numbers= data.frame(inputdata = c(minmz, maxmz,number_features, mean_features, medint, pixel_number))
+vectorofactions = "inputdata"
+
+
+#for $method in $methods:
+
+    #if str( $method.methods_conditional.method ) == 'Transformation':
+
+        print('transforming')
+        ##transformation
+        maldi_data = transformIntensity(maldi_data, method="$method.methods_conditional.transform_method")
+        ## QC plot and numbers
+        avgSpectra = averageMassSpectra(maldi_data,method="mean")
+        plot(avgSpectra, main="Average spectrum after transformation")
+        pixel_number = length(maldi_data)
+        minmz = round(min(unlist(lapply(maldi_data,mass))), digits=4)
+        maxmz = round(max(unlist(lapply(maldi_data,mass))), digits=4)
+        mean_features = round(length(unlist(lapply(maldi_data,mass)))/length(maldi_data), digits=2)
+        medint = round(median(unlist(lapply(maldi_data,intensity))), digits=2)
+        number_features = length(unique(unlist(lapply(maldi_data,mass))))
+        transformed = c(minmz, maxmz,number_features,mean_features,medint,pixel_number)
+        QC_numbers= cbind(QC_numbers, transformed)
+        vectorofactions = append(vectorofactions, "transformed")
+
+
+    #elif str( $method.methods_conditional.method ) == 'Smoothing':
+
+        print('smoothing')
+        ##smoothing
+
+        #if str($method.methods_conditional.methods_for_smoothing.smooth_method ) == 'SavitzkyGolay':
+        print('SavitzkyGolay')
+
+            maldi_data = smoothIntensity(maldi_data,
+                    method="SavitzkyGolay", polynomialOrder=$method.methods_conditional.methods_for_smoothing.polynomial,
+                    halfWindowSize=$method.methods_conditional.halfWindowSize)
+
+        #elif str($method.methods_conditional.methods_for_smoothing.smooth_method ) == 'MovingAverage':
+            print('MovingAverage')
+
+            maldi_data = smoothIntensity(maldi_data,
+                    method="MovingAverage", weighted=$method.methods_conditional.methods_for_smoothing.weighted,
+                    halfWindowSize=$method.methods_conditional.halfWindowSize)
+
+        #end if
+
+        ## QC plot and numbers
+        avgSpectra = averageMassSpectra(maldi_data,method="mean")
+        plot(avgSpectra, main="Average spectrum after smoothing", sub="")
+        pixel_number = length(maldi_data)
+        minmz = round(min(unlist(lapply(maldi_data,mass))), digits=4)
+        maxmz = round(max(unlist(lapply(maldi_data,mass))), digits=4)
+        mean_features = round(length(unlist(lapply(maldi_data,mass)))/length(maldi_data), digits=2)
+        medint = round(median(unlist(lapply(maldi_data,intensity))), digits=2)
+        number_features = length(unique(unlist(lapply(maldi_data,mass))))
+        smoothed = c(minmz, maxmz,number_features,mean_features,medint,pixel_number)
+        QC_numbers= cbind(QC_numbers, smoothed)
+        vectorofactions = append(vectorofactions, "smoothed")
+
+
+    #elif str( $method.methods_conditional.method ) == 'Baseline':
+
+        print('baseline removing')
+        ## Remove baseline
+
+        ## Choose random spectra for QC plots
+        random_spectra = sample(1:length(maldi_data), 4, replace=FALSE)
+
+        #if str($method.methods_conditional.methods_for_baseline.baseline_method ) == 'SNIP':
+        print('SNIP')
+
+            par(mfrow = c(2,2))
+            for (random_sample in random_spectra){
+                maldi_data_baseline = estimateBaseline(maldi_data[[random_sample]],
+                    method="SNIP", iterations=$method.methods_conditional.methods_for_baseline.iterations)
+                plot(maldi_data[[random_sample]], sub="", main=paste0("Estimated baseline for spectrum ", random_sample))
+                lines(maldi_data_baseline, col="blue", lwd=2)}
+
+            maldi_data = removeBaseline(maldi_data,
+                method="SNIP",
+                iterations=$method.methods_conditional.methods_for_baseline.iterations)
+
+
+        #elif str($method.methods_conditional.methods_for_baseline.baseline_method ) == 'TopHat':
+        print('TopHat')
+
+            par(mfrow = c(2,2))
+            for (random_sample in random_spectra){
+                maldi_data_baseline = estimateBaseline(maldi_data[[random_sample]],
+                    method="TopHat", halfWindowSize=$method.methods_conditional.methods_for_baseline.tophat_halfWindowSize)
+                plot(maldi_data[[random_sample]], sub="", main=paste0("Estimated baseline for spectrum ", random_sample))
+                lines(maldi_data_baseline, col="blue", lwd=2)}
+
+            maldi_data = removeBaseline(maldi_data,
+                method="TopHat",
+                halfWindowSize=$method.methods_conditional.methods_for_baseline.tophat_halfWindowSize)
+
+
+        #elif str($method.methods_conditional.methods_for_baseline.baseline_method ) == 'ConvexHull':
+        print('ConvexHull')
+
+            par(mfrow = c(2,2))
+            for (random_sample in random_spectra){
+                maldi_data_baseline = estimateBaseline(maldi_data[[random_sample]],
+                    method="ConvexHull")
+                plot(maldi_data[[random_sample]], sub="", main=paste0("Estimated baseline for spectrum ", random_sample))
+                lines(maldi_data_baseline, col="blue", lwd=2)}
+
+            maldi_data = removeBaseline(maldi_data,
+                method="ConvexHull")
+
+
+        #elif str($method.methods_conditional.methods_for_baseline.baseline_method ) == 'median':
+        print('median')
+
+            par(mfrow = c(2,2))
+            for (random_sample in random_spectra){
+                maldi_data_baseline = estimateBaseline(maldi_data[[random_sample]],
+                    method="median", halfWindowSize=$method.methods_conditional.methods_for_baseline.median_halfWindowSize)
+                plot(maldi_data[[random_sample]], sub="", main=paste0("Estimated baseline for spectrum ", random_sample))
+                lines(maldi_data_baseline, col="blue", lwd=2)}
+
+            maldi_data = removeBaseline(maldi_data,
+                method="median",
+                halfWindowSize=$method.methods_conditional.methods_for_baseline.median_halfWindowSize)
+
+        #end if
+
+        ## QC plot and numbers
+        par(mfrow = c(1,1))
+        avgSpectra = averageMassSpectra(maldi_data,method="mean")
+        plot(avgSpectra, main="Average spectrum after baseline removal")
+        pixel_number = length(maldi_data)
+        minmz = round(min(unlist(lapply(maldi_data,mass))), digits=4)
+        maxmz = round(max(unlist(lapply(maldi_data,mass))), digits=4)
+        mean_features = round(length(unlist(lapply(maldi_data,mass)))/length(maldi_data), digits=2)
+        medint = round(median(unlist(lapply(maldi_data,intensity))), digits=2)
+        number_features = length(unique(unlist(lapply(maldi_data,mass))))
+        baseline_removed = c(minmz, maxmz,number_features,mean_features,medint,pixel_number)
+        QC_numbers= cbind(QC_numbers, baseline_removed)
+        vectorofactions = append(vectorofactions, "bl_removed")
+
+
+    #elif str( $method.methods_conditional.method ) == 'Calibrate':
+
+        print('calibrate')
+        ##calibrate
+
+        #if str($method.methods_conditional.cond_calibration_range) == "yes":
+            ## calibrate only given m/z range
+            maldi_data = calibrateIntensity(maldi_data,
+                method="$method.methods_conditional.calibrate_method",
+                range=c($method.methods_conditional.cond_calibration_range.mass_start, $method.methods_conditional.cond_calibration_range.mass_end))
+        #else:
+            maldi_data = calibrateIntensity(maldi_data,
+            method="$method.methods_conditional.calibrate_method")
+        #end if
+        ## QC plot and numbers
+        avgSpectra = averageMassSpectra(maldi_data,method="mean")
+        plot(avgSpectra, main="Average spectrum after normalization")
+        pixel_number = length(maldi_data)
+        minmz = round(min(unlist(lapply(maldi_data,mass))), digits=4)
+        maxmz = round(max(unlist(lapply(maldi_data,mass))), digits=4)
+        mean_features = round(length(unlist(lapply(maldi_data,mass)))/length(maldi_data), digits=2)
+        medint = round(median(unlist(lapply(maldi_data,intensity))), digits=2)
+        number_features = length(unique(unlist(lapply(maldi_data,mass))))
+        intensity_calibrated = c(minmz, maxmz,number_features,mean_features,medint,pixel_number)
+        QC_numbers= cbind(QC_numbers, intensity_calibrated)
+        vectorofactions = append(vectorofactions, "calibrated")
+
+
+    #elif str( $method.methods_conditional.method ) == 'Align':
+
+        print('align')
+        ##align spectra with 3 separate functions
+
+        ## create reference if needed
+
+        ## 1) detect peaks:
+        peaks <- detectPeaks(maldi_data, halfWindowSize=$method.methods_conditional.halfWindowSize,
+                       method="$method.methods_conditional.peak_method", SNR=$method.methods_conditional.snr)
+
+
+        #if str($method.methods_conditional.reference_for_alignment.align_ref) == 'no_reference':
+
+        ## 2) 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)
+
+        ## 3) warp spectra:
+            maldi_data = warpMassSpectra(maldi_data, 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')
+
+                ## 2) 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)
+
+                ## 3) warp spectra:
+                    maldi_data = warpMassSpectra(maldi_data, warping_function, emptyNoMatches=$method.methods_conditional.empty_nomatch)
+
+            #elif str($method.methods_conditional.reference_for_alignment.separate_alignment) == "TRUE"
+            print('spectra wise alignment')
+
+                maldi_data_new_list =list()
+
+                for (pixelnb in 1:length(peaks))
+                {
+                    ## 2) 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)
+
+                    ## 3) warp spectra:
+                        maldi_data_new = warpMassSpectra(list(maldi_data[[pixelnb]]), warping_function, emptyNoMatches=$method.methods_conditional.empty_nomatch)
+                        maldi_data_new_list = c(maldi_data_new_list, maldi_data_new)
+
+                }
+                maldi_data = maldi_data_new_list
+            #end if
+        #end if
+
+
+        #if $method.methods_conditional.remove_empty:
+            print(paste(length(findEmptyMassObjects(maldi_data)), " empty spectra were removed", sep=" "))
+
+            ## only if there are empty spectra to remove
+
+            if (length(findEmptyMassObjects(maldi_data))>0)
+
+                {
+                    #if $infile.ext == 'rdata'
+                        cardinal_coordinates = cardinal_coordinates[-findEmptyMassObjects(maldi_data),,drop=FALSE] ## remove coordinates of empty spectra for Cardinal RData input
+                    #end if
+
+                    maldi_data = removeEmptyMassObjects(maldi_data)
+            }
+        #end if
+
+        ## QC plot
+
+        if (length(maldi_data)>0){
+            avgSpectra = averageMassSpectra(maldi_data,method="mean")
+            plot(avgSpectra, main="Average spectrum after alignment")
+            medint = round(median(unlist(lapply(maldi_data,intensity))), digits=2)
+        }else{print("All spectra are empty")}
+
+        pixel_number = length(maldi_data)
+        minmz = round(min(unlist(lapply(maldi_data,mass))), digits=4)
+        maxmz = round(max(unlist(lapply(maldi_data,mass))), digits=4)
+        mean_features = round(length(unlist(lapply(maldi_data,mass)))/length(maldi_data), digits=2)
+
+        number_features = length(unique(unlist(lapply(maldi_data,mass))))
+        spectra_aligned = c(minmz, maxmz,number_features,mean_features, medint,pixel_number)
+        QC_numbers= cbind(QC_numbers, spectra_aligned)
+        vectorofactions = append(vectorofactions, "aligned")
+
+    #elif str( $method.methods_conditional.method ) == 'skip_preprocessing':
+        ##for now as option to filter large files
+
+    #end if
+
+#end for
+
+rownames(QC_numbers) = c("min m/z", "max mz", "# features", "median \n# peaks (int.>0)", "median\nintensity", "pixel\nnumber")
+colnames(QC_numbers) = vectorofactions
+plot(0,type='n',axes=FALSE,ann=FALSE)
+grid.table(t(QC_numbers))
+
+dev.off()
+
+## export imzML file
+if (length(maldi_data)>0){
+    #if $infile.ext == 'rdata'
+        MALDIquantForeign::exportImzMl(maldi_data, file="out.imzMl", processed=$export_processed, coordinates=cardinal_coordinates)
+    #else
+        MALDIquantForeign::exportImzMl(maldi_data, file="out.imzMl", processed=$export_processed)
+    #end if
+
+}else{"All spectra are empty, outputfiles will be empty,too."}
+
+    ]]>
+        </configfile>
+    </configfiles>
+    <inputs>
+        <param name="infile" type="data" format="imzml,rdata,analyze75" label="MSI data" help="Input file as imzML (composite upload), or Cardinal MSImageSet saved as RData (regular upload). The file must be in profile mode, not centroided."/>
+        <conditional name="restriction_conditional">
+            <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"/>
+                <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>
+        <repeat name="methods" title="Method" min="1">
+            <conditional name="methods_conditional">
+                <param name="method" type="select" label="Select a method">
+                    <option value="Transformation" selected="True">Transformation</option>
+                    <option value="Smoothing">Smoothing</option>
+                    <option value="Baseline">Baseline removal</option>
+                    <option value="Calibrate">Intensity calibration (normalization)</option>
+                    <option value="Align">Align spectra (warping/phase correction)</option>
+                    <option value="skip_preprocessing">Skip preprocessing</option>
+                    <validator type="empty_field" />
+                </param>
+                <when value="Transformation">
+                    <param name="transform_method" type="select" label="Transformation method">
+                        <option value="sqrt" selected="True">sqrt</option>
+                        <option value="log">log</option>
+                        <option value="log2">log2</option>
+                        <option value="log10">log10</option>
+                        <validator type="empty_field" />
+                    </param>
+                </when>
+                <when value="Smoothing">
+                    <conditional name="methods_for_smoothing">
+                        <param name="smooth_method" type="select" label="Smoothing method" help="This method smoothes the intensity values of a MassSpectrum object.">
+                            <option value="SavitzkyGolay" selected="True">SavitzkyGolay</option>
+                            <option value="MovingAverage">MovingAverage</option>
+                        </param>
+                        <when value="SavitzkyGolay">
+                            <param name="polynomial" value="3" type="text" label="Polynomial order"
+                                    help="Controls the order of the filter, should be smaller than the resulting window."/>
+                        </when>
+                        <when value="MovingAverage">
+                            <param name="weighted" type="boolean" label="Weighted average" help = "Indicates if the average should be equal weight or if it should have weights depending on the distance from the center as calculated as 1/2^abs(-halfWindowSize:halfWindowSize) with the sum of all weigths normalized to 1" truevalue="TRUE" falsevalue="FALSE"/>
+                        </when>
+                    </conditional>
+                    <param name="halfWindowSize" type="integer" value="10"
+                        label="Half window size"
+                        help="Number of data points, the resulting window reaches from 
+                            mass[currentIndex-halfWindowSize] to mass[currentIndex+halfWindowSize]
+                            (window size is 2*halfWindowSize+1)."/>
+                </when>
+                <when value="Baseline">
+                    <conditional name="methods_for_baseline">
+                        <param name="baseline_method" type="select" label="Baseline removal method">
+                            <option value="SNIP" selected="True">SNIP</option>
+                            <option value="TopHat">TopHat</option>
+                            <option value="ConvexHull">ConvexHull</option>
+                            <option value="median">median</option>
+                            <validator type="empty_field" />
+                        </param>
+                        <when value="SNIP">
+                            <param name="iterations" type="integer" value="100"
+                        label="Number of iterations" help="Corresponds to half window size: The resulting window reaches from mass[cur_index-iterations] to mass[cur_index+iterations]"/>
+                        </when>
+                        <when value="TopHat">
+                            <param name="tophat_halfWindowSize" type="integer" value="10"
+                        label="Half window size"
+                            help="Number of data points, the resulting window reaches from 
+                            mass[currentIndex-halfWindowSize] to mass[currentIndex+halfWindowSize]"/>
+                        </when>
+                        <when value="ConvexHull"/>
+                        <when value="median">
+                            <param name="median_halfWindowSize" type="integer" value="10"
+                        label="Half window size"
+                            help="Number of data points, the resulting window reaches from 
+                            mass[currentIndex-halfWindowSize] to mass[currentIndex+halfWindowSize]"/>
+                        </when>
+                    </conditional>
+                </when>
+                <when value="Calibrate">
+                    <param name="calibrate_method" type="select" label="Intensity calibration method" help="Intensity normalization">
+                        <option value="TIC" selected="True">TIC</option>
+                        <option value="PQN">PQN</option>
+                        <option value="median">median</option>
+                        <validator type="empty_field" />
+                    </param>
+                    <conditional name="cond_calibration_range">
+                        <param name="calibration_range" type="select" label="m/z range" help="Instead of the whole m/z range, a specified m/z range can be used to calculate the scaling factor.">
+                            <option value="no" selected="True">complete m/z range</option>
+                            <option value="yes">specify a m/z range</option>
+                        </param>
+                        <when value="no"/>
+                        <when value="yes">
+                            <param name="mass_start" type="integer" value="800"
+                                label="Start of m/z range, has to be inside m/z range" 
+                                help="Scaling factor is calculated on the mass range and applied to the whole spectrum."/>
+                            <param name="mass_end" type="integer" value="3000"
+                                label="End of m/z range, has to be inside m/z range"/>
+                        </when>
+                    </conditional>
+                </when>
+                <when value="Align">
+                    <param name="warping_method" type="select" label="Alignment method">
+                        <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"
+                        help="abs(mz1 - mz2)/mz2, maximal relative deviation of a peak position (m/z) to be considered as identical. For 50ppm use 0.00005 or 5e-5" />
+
+                    <param name="halfWindowSize" type="integer" value="20"
+                        label="Half window size"
+                        help="Number of data points, the resulting window reaches from 
+                            mass[currentIndex-halfWindowSize] to mass[currentIndex+halfWindowSize]
+                            (window size is 2*halfWindowSize+1).
+                            The best size differs depending on the selected smoothing method."/>
+
+                    <param name="peak_method" type="select" label="Noise estimation function">
+                        <option value="MAD" selected="True">MAD</option>
+                        <option value="SuperSmoother">SuperSmoother</option>
+                    </param>
+
+                    <param name="snr" type="integer" value="2" label="Signal-to-noise-ratio"/>
+                    <param name="allow_nomatch" type="boolean" label="Allow no matches" help="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="Empty no matches" help="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="Remove empty spectra" 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="skip_preprocessing"/>
+            </conditional>
+        </repeat>
+        <param name="export_processed" type="boolean" label="Export processed imzML" help="otherwise continuous imzML will be exported" truevalue="TRUE" falsevalue="FALSE"/>
+    </inputs>
+    <outputs>
+        <data format="imzml" name="outfile_imzml" label="${tool.name} on ${on_string}" />
+        <data format="pdf" name="plots" from_work_dir="prepro_qc_plot.pdf" label="${tool.name} on ${on_string}: QC"/>
+    </outputs>
+    <tests>
+        <test>
+            <param name="infile" value="" ftype="imzml">
+                <composite_data value="Example_Continuous.imzML"/>
+                <composite_data value="Example_Continuous.ibd"/>
+            </param>
+            <conditional name="restriction_conditional">
+                <param name="restriction" value="restrict"/>
+                <param name="coordinates_file" value="restricted_pixels.tabular"/>
+                <param name="column_x" value="1"/>
+                <param name="column_y" value="2"/>
+            </conditional>
+            <conditional name="methods_conditional">
+                <param name="method" value="Transformation"/>
+                <param name="transform_method" value="log2"/>
+                <param name="method" value="Smoothing"/>
+                <param name="smooth_method" value="SavitzkyGolay"/>
+                <param name="method" value="Basline"/>
+                <param name="baseline_method" value ="TopHat"/>
+            </conditional>
+            <output name="outfile_imzml" ftype="imzml" file="preprocessing1.imzml.txt" lines_diff="4">
+                <extra_files type="file" file="outfile1.imzml" name="imzml" lines_diff="6"/>
+                <extra_files type="file" file="outfile1.ibd" name="ibd" compare="sim_size"/>
+            </output>
+            <output name="plots" file="Preprocessing1_QC.pdf" compare="sim_size"/>
+        </test>
+        <test>
+            <param name="infile" value="msidata_1.RData" ftype="rdata"/>
+            <conditional name="methods_conditional">
+                <param name="method" value="Align"/>
+                <param name="warping_method" value="lowess"/>
+                <param name="halfWindowSize" value="5"/>
+                <param name="tolerance" value="0.001"/>
+                <param name="allow_nomatch" value="TRUE"/>
+                <param name="remove_empty" value="TRUE"/>
+                <param name="empty_nomatch" value="TRUE"/>
+                <conditional name="reference_for_alignment">
+                    <param name="align_ref" value="yes_reference"/>
+                    <param name="reference_file" value="inputpeptides.tabular" ftype="tabular"/>
+                </conditional>
+            </conditional>
+            <output name="outfile_imzml" ftype="imzml" file="preprocessing2.imzml.txt" lines_diff="4">
+                <extra_files type="file" file="outfile2.imzml" name="imzml" lines_diff="6"/>
+                <extra_files type="file" file="outfile2.ibd" name="ibd" compare="sim_size"/>
+            </output>
+            <output name="plots" file="Preprocessing2_QC.pdf" compare="sim_size"/>
+        </test>
+        <test>
+            <param name="infile" value="" ftype="imzml">
+                <composite_data value="Example_Continuous.imzML"/>
+                <composite_data value="Example_Continuous.ibd"/>
+            </param>
+            <conditional name="methods_conditional">
+                <param name="method" value="Calibrate"/>
+                <param name="calibrate_method" value="median"/>
+            </conditional>
+            <output name="outfile_imzml" ftype="imzml" file="preprocessing3.imzml.txt" lines_diff="4">
+                <extra_files type="file" file="outfile3.imzml" name="imzml" lines_diff="6"/>
+                <extra_files type="file" file="outfile3.ibd" name="ibd" compare="sim_size"/>
+            </output>
+            <output name="plots" file="Preprocessing3_QC.pdf" compare="sim_size"/>
+        </test>
+    </tests>
+    <help><![CDATA[
+
+@MADLI_QUANT_DESCRIPTION@
+
+-----
+
+**Input data**
+
+- MSI data: 2 types of input data can be used:
+
+    - imzml file (upload imzml and ibd file via the "composite" function) `Introduction to the imzml format <https://ms-imaging.org/wp/imzml/>`_
+    - Cardinal "MSImageSet" data saved as .RData
+
+- 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. 
+
+    ::
+
+       x_coord     y_coord 
+         1            1    
+         2            1    
+         3            1    
+        ...
+        ...
+
+- Optional: Tabular file with reference m/z for the spectra align function. At least 2 m/z values of the input list must be present in every spectrum to peform the alignment. First column must contain m/z values, without empty fields or letters. Tabular files with any header name or no header at all are supported. 
+
+    ::
+
+    
+            m/z
+          100.0
+          100.01
+          100.02
+        ...
+        ...    
+
+
+
+**Options**
+
+- Transformation: Variance stabilization through intensity transformation:'log', 'log2', 'log10' and 'squareroot' (sqrt) are available
+- Smoothing: Smoothing of the peaks reduces noise and improves peak detection. Available smoothing methods are 'SavitzkyGolay' and 'Moving Average'
+
+    - For all smoothing methods: The larger the 'Half window size', the stronger the smoothing. The resulting window should be smaller than the FWHM (full width at half maximum) of the typical peaks. Moving average needs smaller window size than SavitzkyGolay.
+    - Moving average: Recommended for broader peaks/high m/z range spectra. Weighted moving average: Points in the center get larger weight factors than points away from the center.  
+    - SavitzkyGolay: Recommended for sharp peaks/low m/z range, preserves the shape of the local maxima. The PolynomialOrder should be smaller than the resulting window. Negative values will be replaced with 0. 
+
+- Baseline reduction: Baseline reduction removes background intensity generated by chemical noise (common in MALDI datasets). 
+
+    - Available methods are SNIP, TopHat,ConvexHull and median:
+    - SNIP is the default baseline reduction method in MALDIquant. 
+    - ConvexHull is not appropriate for MALDI-TOF baseline removal. 
+    - The moving median may generate negative intensities. 
+    - Except for the ConvexHull all methods have a parameter for the 'Half window size' (in SNIP it is called 'iterations'). The smaller the window the more baseline will be removed but also parts of the peaks. Wider windows preserve the peak height better and produce a smoother baseline, but some local background variation will remain. 
+
+- Intensity calibration (normalization): Normalization of intensities to Total Ion Current (TIC), median spectrum, Probabilistic Quotient Normalization (PQN)
+
+    - TIC and median are local calibration methods: each spectrum is normalized on its own (each peak is divided by the TIC or median of the spectrum)
+    - PQN is a global calibration method: In PQN all spectra are calibrated using the TIC calibration first. Subsequently, a median reference spectrum is created and the intensities in all spectra are standardized using the reference spectrum and a spectrum-specific median is calculated for each spectrum. Finally, each spectrum is rescaled by the median of the ratios of its intensity values and that of the reference spectrum
+
+- Spectra alignment (warping): alignment for (re)calibration of m/z values. 
+
+    - peak detection is performed, the reference peaks will be matched to those detected peaks
+    - without external reference m/z: internal reference is obtained by filtering and binning the picked peaks to find landmark peaks and their average m/z
+    - with external reference m/z: the given m/z 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 present (picked) peaks with the given tolerance. At least two m/z per spectrum are needed for the alignment. To prevent an error when this criterium is not fullfilled, "Don't throw an error when less than 2 reference m/z were found in a spectrum" should be set 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. 
+
+
+**Output**
+
+- imzML file (imzML format can be continuous or processed)
+- PDF with average mass spectra after each preprocessing step
+
+.. _MALDIquant: http://strimmerlab.org/software/maldiquant/
+
+        ]]>
+    </help>
+    <expand macro="citation"/>
+</tool>
+
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:31:55 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:00 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:31:55 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:00 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:31:55 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:00 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:31:55 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:00 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:00 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:00 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:00 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:00 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:00 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:00 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:00 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:00 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:00 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:00 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