changeset 10:3eee933c27cf draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msi_qualitycontrol commit 37da74ed68228b16efbdbde776e7c38cc06eb5d5
author galaxyp
date Tue, 19 Jun 2018 18:08:15 -0400
parents 963c7ec00141
children 30d0aabb1b46
files msi_qualitycontrol.xml test-data/Example_Continuous.ibd test-data/Example_Continuous.imzML test-data/Example_Processed.ibd test-data/Example_Processed.imzML test-data/QC_analyze75.pdf test-data/QC_empty_spectra.pdf test-data/QC_imzml.pdf test-data/QC_rdata.pdf test-data/spectra_info_123_combi.txt test-data/spectra_info_imzml.txt
diffstat 11 files changed, 589 insertions(+), 396 deletions(-) [+]
line wrap: on
line diff
--- a/msi_qualitycontrol.xml	Mon Jun 11 17:34:19 2018 -0400
+++ b/msi_qualitycontrol.xml	Tue Jun 19 18:08:15 2018 -0400
@@ -1,4 +1,4 @@
-<tool id="mass_spectrometry_imaging_qc" name="MSI Qualitycontrol" version="1.10.0.1">
+<tool id="mass_spectrometry_imaging_qc" name="MSI Qualitycontrol" version="1.10.0.2">
     <description>
         mass spectrometry imaging QC
     </description>
@@ -8,6 +8,7 @@
         <requirement type="package" version="1.1_2">r-rcolorbrewer</requirement>
         <requirement type="package" version="2.2.1">r-gridextra</requirement>
         <requirement type="package" version="2.23_15">r-kernsmooth</requirement>
+        <requirement type="package" version="0.5.0">r-scales</requirement>
     </requirements>
     <command detect_errors="exit_code">
     <![CDATA[
@@ -35,15 +36,19 @@
 library(RColorBrewer)
 library(gridExtra)
 library(KernSmooth)
+library(scales)
 
 #if $infile.ext == 'imzml'
-    msidata = readImzML('infile')
+    msidata <- readImzML('infile', mass.accuracy=$accuracy, units.accuracy = "$units")
 #elif $infile.ext == 'analyze75'
     msidata = readAnalyze('infile')
 #else
     load('infile.RData')
 #end if
 
+## create full matrix to make processed imzML files compatible with segmentation
+iData(msidata) <- iData(msidata)[] 
+
 ###################################### file properties in numbers ######################
 
 ## Number of features (m/z)
@@ -73,7 +78,7 @@
 TICs = colSums(spectra(msidata)[]) 
 NumemptyTIC = sum(TICs == 0)
 ## Median TIC
-medTIC = median(TICs)
+medTIC = round(median(TICs), digits=2)
 ## Median peaks per spectrum
 medpeaks = median(colSums(spectra(msidata)[]>0))
 print(cor(TICs,colSums(spectra(msidata)[]>0), method="pearson"))
@@ -109,7 +114,6 @@
   peakpickinginfo=processinginfo@peakPicking
 }
 
-
 ############## Read and filter tabular file with m/z ###########################
 
 ### reading peptide file: 
@@ -183,10 +187,10 @@
 
 ################# I) file properties in numbers ################################
 ################################################################################
-    print("properties in numbers")
+print("properties in numbers")
 
 properties = c("Number of m/z features",
-               "Range of m/z values [Da]",
+               "Range of m/z values",
                "Number of pixels", 
                "Range of x coordinates", 
                "Range of y coordinates",
@@ -223,16 +227,15 @@
            paste0(number_peptides_valid, " / " , number_peptides_in),
            paste0(number_calibrants_valid, " / ", number_calibrants_in))
 
-
 property_df = data.frame(properties, values)
 
 grid.table(property_df, rows= NULL)
 
-    ####################### II) images in x-y grid ###############################
-    ##############################################################################
-    print("x-y images")
+####################### II) images in x-y grid ###############################
+##############################################################################
+print("x-y images")
+
 if (npeaks > 0){
-
     ## function for density plots
     plot_colorByDensity = function(x1,x2,
                                    ylim=c(min(x2),max(x2)),
@@ -248,10 +251,35 @@
 
     abline_vector= -100000 ## will be filled for samples in case data is combined
 
+    ## start list for optional spectrum values output
+    spectrum_list = list()
+    list_count = 1
+
     ################### 0) overview for combined data ###########################
 
     ### only for previously combined data, same plot as in combine QC pdf
+
     if (!is.null(levels(msidata\$combined_sample))){
+        number_combined = length(levels(msidata\$combined_sample))
+
+        ## the more combined_samples a file has the smaller will be the legend
+        if (number_combined<20){
+            legend_size = 10
+            cex_boxplot = 1
+        }else if (number_combined>20 && number_combined<40){
+            legend_size = 9
+            cex_boxplot = 0.8
+        }else if (number_combined>40 && number_combined<60){
+            legend_size = 8
+            cex_boxplot = 0.6
+        }else if (number_combined>60 && number_combined<100){
+            legend_size = 7
+            cex_boxplot = 0.5
+        }else{
+            legend_size = 6
+            cex_boxplot = 0.3
+        }
+
         position_df = cbind(coord(msidata)[,1:2], msidata\$combined_sample)
         colnames(position_df)[3] = "sample_name"
 
@@ -260,37 +288,40 @@
                coord_fixed()+
                ggtitle("Spatial orientation of combined data")+
                theme_bw()+
-               theme(text=element_text(family="ArialMT", face="bold", size=15))+
+               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")+
-               guides(fill=guide_legend(ncol=4,byrow=TRUE))
+               theme(legend.key.size = unit(0.2, "line"), legend.text = element_text(size = legend_size))+
+               guides(fill=guide_legend(ncol=5,byrow=TRUE))
         coord_labels = aggregate(cbind(x,y)~sample_name, data=position_df, mean)
         coord_labels\$file_number = gsub( "_.*$", "", coord_labels\$sample_name)
         for(file_count in 1:nrow(coord_labels))
-        {combine_plot = combine_plot + annotate("text",x=coord_labels[file_count,"x"],
-        y=coord_labels[file_count,"y"],label=toString(coord_labels[file_count,4]))}
+            {combine_plot = combine_plot + annotate("text",x=coord_labels[file_count,"x"],
+            y=coord_labels[file_count,"y"],label=toString(coord_labels[file_count,4]))}
+
         print(combine_plot)
 
-        ### find max pixelnumber per subsample to later draw ablines
+        ### find max pixelnumber per subsample to later draw ablines 
         pixel_name_df = data.frame(pixels(msidata), msidata\$combined_sample)
         colnames(pixel_name_df) = c("pixel_number", "pixel_name")
         last_pixel = aggregate(pixel_number~pixel_name, data = pixel_name_df, max)
         pixel_vector = last_pixel[,2]
-        abline_vector = pixel_vector[1:length(levels(msidata\$combined_sample))-1]
+        abline_vector = pixel_vector[1:number_combined-1]
         print(abline_vector)
-        }
-
+    }
 
     ################### 1) Pixel order image ###################################
 
     pixelnumber = 1:pixelcount
     pixelxyarray=cbind(coord(msidata)[,1:2],pixelnumber)
 
-    print(ggplot(pixelxyarray, aes(x=x, y=y, fill=pixelnumber))
-     + geom_tile() + coord_fixed()
-     + ggtitle("Pixel order")
-     +theme_bw()
-     + scale_fill_gradientn(colours = c("blue", "purple" , "red","orange"), 
-       space = "Lab", na.value = "black", name = "Acq"))
+    print(ggplot(pixelxyarray, aes(x=x, y=y, fill=pixelnumber))+
+     geom_tile() + coord_fixed()+
+     ggtitle("Pixel order") + theme_bw()+
+     theme(plot.title = element_text(hjust = 0.5))+
+     theme(text=element_text(family="ArialMT", face="bold", size=12))+
+     scale_fill_gradientn(colours = c("blue", "purple" , "red","orange"), 
+       space = "Lab", na.value = "black", name = "Pixel number"))
 
     ################ 2) Number of calibrants per spectrum ######################
 
@@ -321,13 +352,20 @@
         countdf= cbind(coord(msidata)[,1:2], countvector)
         mycolours = c("black","grey", "darkblue", "blue", "green" , "red", "yellow", "magenta", "olivedrab1", "lightseagreen")
 
-        print(ggplot(countdf, aes(x=x, y=y, fill=countvector))
-          + geom_tile() + coord_fixed() 
-          + ggtitle("Number of calibrants per pixel")
-          + theme_bw() 
-          + theme(text=element_text(family="ArialMT", face="bold", size=12))
-          + scale_fill_manual(values = mycolours[1:length(countvector)], 
+        print(ggplot(countdf, aes(x=x, y=y, fill=countvector))+
+          geom_tile() + coord_fixed() +
+          ggtitle("Number of calibrants per pixel") +
+          theme_bw() +
+          theme(plot.title = element_text(hjust = 0.5))+
+          theme(text=element_text(family="ArialMT", face="bold", size=12))+
+          scale_fill_manual(values = mycolours[1:length(countvector)], 
                                 na.value = "black", name = "# calibrants"))
+
+        ## append list for optional spectrum values output
+        colnames(countdf)[3] = "Number of Calibrants"
+        spectrum_list[[list_count]] = countdf
+        list_count = list_count+1
+
     }else{print("2) The inputcalibrant m/z were not provided or outside the m/z range")}
 
     ########################## 3) fold change image ###########################
@@ -386,12 +424,13 @@
                 foldchange= log2(mass1vector/mass2vector)
                 fcmatrix = cbind(foldchange, coord(msidata)[,1:2])
 
-                print(ggplot(fcmatrix, aes(x=x, y=y, fill=foldchange), colour=colo)
-                 + geom_tile() + coord_fixed()
-                 + ggtitle("$label")
-                 + theme_bw()
-                 + theme(text=element_text(family="ArialMT", face="bold", size=12))
-                 + scale_fill_gradientn(colours = c("blue", "purple" , "red","orange")
+                print(ggplot(fcmatrix, aes(x=x, y=y, fill=foldchange), colour=colo)+
+                 geom_tile() + coord_fixed()+
+                 ggtitle("$label")+
+                 theme_bw()+
+                 theme(plot.title = element_text(hjust = 0.5))+
+                 theme(text=element_text(family="ArialMT", face="bold", size=12))+
+                 scale_fill_gradientn(colours = c("blue", "purple" , "red","orange")
                                         ,space = "Lab", na.value = "black", name ="FC"))
             }else{
                 plot(0,type='n',axes=FALSE,ann=FALSE)
@@ -407,7 +446,7 @@
         for (mass in 1:length(inputmasses)){
             image(msidata, mz=inputmasses[mass], plusminus=$plusminus_dalton, 
             main= paste0(inputnames[mass], " (", round(inputmasses[mass], digits = 2)," ± ", $plusminus_dalton, " Da)"),
-            contrast.enhance = "histogram")
+            contrast.enhance = "histogram", ylim= c(maximumy+0.2*maximumy,minimumy-0.2*minimumy))
         }
     } else {print("4) The input peptide and calibrant m/z were not provided or outside the m/z range")}
 
@@ -417,41 +456,54 @@
     peaksperpixel = colSums(spectra(msidata)[]> 0)
     peakscoordarray=cbind(coord(msidata)[,1:2], peaksperpixel)
 
-    print(ggplot(peakscoordarray, aes(x=x, y=y, fill=peaksperpixel), colour=colo)
-     + geom_tile() + coord_fixed() 
-     + ggtitle("Number of peaks per spectrum")
-     + theme_bw() 
-     + theme(text=element_text(family="ArialMT", face="bold", size=12))
-     + scale_fill_gradientn(colours = c("blue", "purple" , "red","orange") 
+    print(ggplot(peakscoordarray, aes(x=x, y=y, fill=peaksperpixel), colour=colo)+
+     geom_tile() + coord_fixed() +
+     ggtitle("Number of peaks per spectrum")+
+     theme_bw() +
+     theme(plot.title = element_text(hjust = 0.5))+
+     theme(text=element_text(family="ArialMT", face="bold", size=12))+
+     scale_fill_gradientn(colours = c("blue", "purple" , "red","orange") 
                             ,space = "Lab", na.value = "black", name = "# peaks"))
 
+    ## append list for optional spectrum values output
+    colnames(peakscoordarray)[3] = "Number of Peaks"
+    spectrum_list[[list_count]] = peakscoordarray
+    list_count = list_count+1
+
     ############################### 6) TIC image ###############################
 
     TICcoordarray=cbind(coord(msidata)[,1:2], TICs)
     colo = colorRampPalette(
     c("blue", "cyan", "green", "yellow","red"))
-    print(ggplot(TICcoordarray, aes(x=x, y=y, fill=TICs), colour=colo)
-     + geom_tile() + coord_fixed() 
-     + ggtitle("Total Ion Chromatogram")
-     + theme_bw() 
-     + theme(text=element_text(family="ArialMT", face="bold", size=12))
-     + scale_fill_gradientn(colours = c("blue", "purple" , "red","orange") 
+    print(ggplot(TICcoordarray, aes(x=x, y=y, fill=TICs), colour=colo)+
+     geom_tile() + coord_fixed() +
+     ggtitle("Total Ion Chromatogram")+
+     theme_bw() +
+     theme(plot.title = element_text(hjust = 0.5))+
+     theme(text=element_text(family="ArialMT", face="bold", size=12))+
+     scale_fill_gradientn(colours = c("blue", "purple" , "red","orange") 
                             ,space = "Lab", na.value = "black", name = "TIC"))
 
+    ## append list for optional spectrum values output
+    colnames(TICcoordarray)[3] = "TIC per spectrum"
+    spectrum_list[[list_count]] = TICcoordarray
+    list_count = list_count+1
+
     ############################### 7) Most abundant m/z image #################
 
     highestmz = apply(spectra(msidata)[],2,which.max) 
     highestmz_matrix = cbind(coord(msidata)[,1:2],mz(msidata)[highestmz])
     colnames(highestmz_matrix)[3] = "highestmzinDa"
 
-    print(ggplot(highestmz_matrix, aes(x=x, y=y, fill=highestmzinDa))
-    + geom_tile() + coord_fixed() 
-    + ggtitle("Most abundant m/z in each spectrum")
-    + theme_bw() 
-    + scale_fill_gradientn(colours = c("blue", "purple" , "red","orange"), space = "Lab", na.value = "black", name = "m/z", 
+    print(ggplot(highestmz_matrix, aes(x=x, y=y, fill=highestmzinDa))+
+    geom_tile() + coord_fixed() +
+    ggtitle("Most abundant m/z in each spectrum")+
+    theme_bw() +
+    theme(plot.title = element_text(hjust = 0.5))+
+    scale_fill_gradientn(colours = c("blue", "purple" , "red","orange"), space = "Lab", na.value = "black", name = "m/z", 
       labels = as.character(pretty(highestmz_matrix\$highestmzinDa)[c(1,3,5,7)]),
-      breaks = pretty(highestmz_matrix\$highestmzinDa)[c(1,3,5,7)], limits=c(min(highestmz_matrix\$highestmzinDa), max(highestmz_matrix\$highestmzinDa)))
-    + theme(text=element_text(family="ArialMT", face="bold", size=12)))
+      breaks = pretty(highestmz_matrix\$highestmzinDa)[c(1,3,5,7)], limits=c(min(highestmz_matrix\$highestmzinDa), max(highestmz_matrix\$highestmzinDa)))+
+    theme(text=element_text(family="ArialMT", face="bold", size=12)))
 
     ## which m/z are highest
     highestmz_peptides = names(sort(table(round(highestmz_matrix\$highestmzinDa, digits=0)), decreasing=TRUE)[1])
@@ -462,12 +514,16 @@
 
     print(head(sort(table(round(highestmz_matrix\$highestmzinDa, digits=0)), decreasing=TRUE)))
 
+    ## append list for optional spectrum values output
+    colnames(highestmz_matrix)[3] = "Most abundant m/z"
+    spectrum_list[[list_count]] = highestmz_matrix
+
     ########################## 8) pca image for two components #################
 
     pca = PCA(msidata, ncomp=2) 
     par(mfrow = c(2,1))
     plot(pca, col=c("black", "darkgrey"), main="PCA for two components")
-    image(pca, col=c("black", "white"), strip=FALSE)
+    image(pca, col=c("black", "white"), strip=FALSE, ylim= c(maximumy+0.2*maximumy,minimumy-0.2*minimumy))
 
     ################## III) properties over spectra index ##########
     ##############################################################################
@@ -498,7 +554,11 @@
         hist_9 = ggplot(df_9, aes(x=Npeaks, fill=sample_name)) +
         geom_histogram()+ theme_bw()+
         theme(text=element_text(family="ArialMT", face="bold", size=12))+
+        theme(plot.title = element_text(hjust = 0.5))+
+        theme(legend.key.size = unit(0.2, "line"), legend.text = element_text(size = legend_size))+
+        theme(legend.position="bottom",legend.direction="vertical")+
         labs(title="Number of peaks per spectrum and sample", x="Number of peaks per spectrum", y = "Frequency = # spectra") +
+        guides(fill=guide_legend(ncol=5,byrow=TRUE))+
         geom_vline(xintercept = median(peaksperpixel), size = 1, colour = "black",linetype = "dashed")
         print(hist_9)}
 
@@ -526,7 +586,11 @@
         hist_10 = ggplot(df_10, aes(x=TICs, fill=sample_name)) +
         geom_histogram()+ theme_bw()+
         theme(text=element_text(family="ArialMT", face="bold", size=12))+
+        theme(plot.title = element_text(hjust = 0.5))+
+        theme(legend.position="bottom",legend.direction="vertical")+
+        theme(legend.key.size = unit(0.2, "line"), legend.text = element_text(size = legend_size))+
         labs(title="TIC per spectrum and sample", x="log(TIC per spectrum)", y = "Frequency = # spectra") +
+        guides(fill=guide_legend(ncol=5,byrow=TRUE))+
         geom_vline(xintercept = median(log(TICs[TICs>0])), size = 1, colour = "black",linetype = "dashed")
         print(hist_10)}
 
@@ -606,6 +670,10 @@
     geom_histogram()+ theme_bw()+
     theme(text=element_text(family="ArialMT", face="bold", size=12))+
     labs(title="Log2-transformed intensities per sample", x="log2 intensities", y = "Frequency") +
+    theme(plot.title = element_text(hjust = 0.5))+
+    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))+
     geom_vline(xintercept = median(log2(spectra(msidata)[(spectra(msidata)>0)])), size = 1, colour = "black",linetype = "dashed")
     print(hist_13)
 
@@ -614,9 +682,11 @@
 
     mean_matrix = matrix(,ncol=0, nrow = nrow(msidata))
     for (subsample in levels(msidata\$combined_sample)){
-        mean_mz_sample = colMeans(spectra(msidata)[,msidata\$combined_sample==subsample])
+        mean_mz_sample = rowMeans(spectra(msidata)[,msidata\$combined_sample==subsample])
         mean_matrix = cbind(mean_matrix, mean_mz_sample)}
-    boxplot(mean_matrix, ylab = "mean intensity per m/z", names=levels(msidata\$combined_sample), main="Mean intensities per m/z and sample", las=2)
+
+    boxplot(log2(mean_matrix), ylab = "log2 mean intensity per m/z", main="Mean intensities per m/z and sample", xaxt = "n")
+    (axis(1, at = c(1:number_combined), labels=levels(msidata\$combined_sample), cex.axis=cex_boxplot, las=2))
     }
 
     ########################## 14) Histogram on m/z values #####################
@@ -671,25 +741,37 @@
 
             par(mfrow = c(2, 2), oma=c(0,0,2,0))
             plot(msidata[minmasspixel:maxmasspixel,], pixel = 1:length(pixelnumber), main= "average spectrum")
-            abline(v=c(inputcalibrantmasses[mass] -plusminusvalues[count], inputcalibrantmasses[mass] ,inputcalibrantmasses[mass] +plusminusvalues[count]), col="blue", lty=c(3,6,3))
-            abline(v=c(maxvalue), col="red", lty=5)
-            abline(v=c(mzvalue), col="green2", lty=5)
+            abline(v=c(inputcalibrantmasses[mass] -plusminusvalues[count], inputcalibrantmasses[mass] ,inputcalibrantmasses[mass] +plusminusvalues[count]), col="blue", lty=c(3,1,3))
+            abline(v=c(maxvalue), col="red", lty=2)
+            abline(v=c(mzvalue), col="green2", lty=4)
             plot(msidata[minmasspixel:maxmasspixel,], pixel = pixels_for_plot[1], main=paste0("Spectrum at ", rownames(coord(msidata)[pixels_for_plot[1],1:2])))
-            abline(v=c(inputcalibrantmasses[mass] -plusminusvalues[count], inputcalibrantmasses[mass] ,inputcalibrantmasses[mass] +plusminusvalues[count]), col="blue", lty=c(3,6,3))
-            abline(v=c(maxvalue), col="red", lty=5)
-            abline(v=c(mzvalue), col="green2", lty=5)
+            abline(v=c(inputcalibrantmasses[mass] -plusminusvalues[count], inputcalibrantmasses[mass] ,inputcalibrantmasses[mass] +plusminusvalues[count]), col="blue", lty=c(3,1,3))
+            abline(v=c(maxvalue), col="red", lty=2)
+            abline(v=c(mzvalue), col="green2", lty=4)
             plot(msidata[minmasspixel:maxmasspixel,], pixel = pixels_for_plot[2], main= paste0("Spectrum at ", rownames(coord(msidata)[pixels_for_plot[2],1:2])))
-            abline(v=c(inputcalibrantmasses[mass] -plusminusvalues[count], inputcalibrantmasses[mass] ,inputcalibrantmasses[mass] +plusminusvalues[count]), col="blue", lty=c(3,6,3))
-            abline(v=c(maxvalue), col="red", lty=5)
-            abline(v=c(mzvalue), col="green2", lty=5)
+            abline(v=c(inputcalibrantmasses[mass] -plusminusvalues[count], inputcalibrantmasses[mass] ,inputcalibrantmasses[mass] +plusminusvalues[count]), col="blue", lty=c(3,1,3))
+            abline(v=c(maxvalue), col="red", lty=2)
+            abline(v=c(mzvalue), col="green2", lty=4)
             plot(msidata[minmasspixel:maxmasspixel,], pixel = pixels_for_plot[3], main= paste0("Spectrum at ", rownames(coord(msidata)[pixels_for_plot[3],1:2])))
-            abline(v=c(inputcalibrantmasses[mass] -plusminusvalues[count], inputcalibrantmasses[mass] ,inputcalibrantmasses[mass] +plusminusvalues[count]), col="blue", lty=c(3,6,3))
-            abline(v=c(maxvalue), col="red", lty=5)
-            abline(v=c(mzvalue), col="green2", lty=5)
+            abline(v=c(inputcalibrantmasses[mass] -plusminusvalues[count], inputcalibrantmasses[mass] ,inputcalibrantmasses[mass] +plusminusvalues[count]), col="blue", lty=c(3,1,3))
+            abline(v=c(maxvalue), col="red", lty=2)
+            abline(v=c(mzvalue), col="green2", lty=4)
             title(paste0("theor. m/z: ", inputcalibrants[count,1]), col.main="blue", outer=TRUE, line=0, adj=0.074)
             title(paste0("most abundant m/z: ", round(maxvalue, digits=4)), col.main="red", outer=TRUE, line=0, adj=0.49)
             title(paste0("closest m/z: ", round(mzvalue, digits=4)), col.main="green2", outer=TRUE, line=0, adj=0.93)
+
+            ### 16b) one large extra plot with different colours for different samples (for combined_sample only)
+
+            if (!is.null(levels(msidata\$combined_sample))){
+                if (number_combined < 10){
+                    key_zoomed = TRUE
+                }else{key_zoomed = FALSE}
+                par(mfrow = c(1, 1))
+                plot(msidata[minmasspixel:maxmasspixel,], pixel=1:ncol(msidata),main="average spectrum per sample",
+                pixel.groups=msidata\$combined_sample, key=key_zoomed, col=hue_pal()(number_combined),superpose=TRUE)
+                abline(v=c(inputcalibrantmasses[mass] -plusminusvalues[count], inputcalibrantmasses[mass] ,inputcalibrantmasses[mass] +plusminusvalues[count]), col="black", lty=c(3,1,3))
             count=count+1
+            }
         }
 
     ######### 17) ppm difference input calibrant m/z and m/z with max intensity in given m/z range#########
@@ -706,7 +788,8 @@
         }else{
 
         diff_plot=ggplot(data=diff_df, aes(x=calibrant_names, y=differencevector)) + geom_bar(stat="identity", fill = "darkgray") + theme_minimal() +
-        labs(title="Difference m/z with max. average intensity vs. theoretical calibrant m/z", x="calibrants", y = "Difference in ppm")+
+        labs(title="Difference m/z with max. average intensity vs. theor. calibrant m/z", x="calibrants", y = "Difference in ppm")+
+        theme(plot.title = element_text(hjust = 0.5))+theme(text=element_text(family="ArialMT", face="bold", size=12))+
         geom_text(aes(label=differencevector), vjust=-0.3, size=3.5, col="blue")
 
         print(diff_plot)}
@@ -720,7 +803,8 @@
         diff_df = data.frame(differencevector2, calibrant_names)
 
         diff_plot=ggplot(data=diff_df, aes(x=calibrant_names, y=differencevector2)) + geom_bar(stat="identity", fill = "darkgray") + theme_minimal() +
-        labs(title="Difference closest measured m/z vs. theoretical calibrant m/z", x="calibrants", y = "Difference in ppm")+
+        labs(title="Difference closest measured m/z vs. theor. calibrant m/z", x="calibrants", y = "Difference in ppm")+
+        theme(plot.title = element_text(hjust = 0.5))+theme(text=element_text(family="ArialMT", face="bold", size=12))+
         geom_text(aes(label=differencevector2), vjust=-0.3, size=3.5, col="blue")
 
         print(diff_plot)
@@ -759,7 +843,7 @@
     ### plot ppm differences over pixels (spectra index)
 
     par(mar=c(4.1, 4.1, 4.1, 7.5))
-    plot(0,0,type="n", ylim=c(min(ppm_df, na.rm=TRUE),max(ppm_df, na.rm=TRUE)), xlim = c(1,ncol(filtered_data)),xlab = "Spectra index", ylab = "m/z difference in ppm", main="Difference m/z with max. average intensity vs. theoretical m/z\n(per spectrum)") 
+    plot(0,0,type="n", ylim=c(min(ppm_df, na.rm=TRUE),max(ppm_df, na.rm=TRUE)), xlim = c(1,ncol(filtered_data)),xlab = "Spectra index", ylab = "m/z difference in ppm", main="Difference m/z with max. average intensity vs. theor. m/z\n(per spectrum)") 
 
     for (each_cal in 1:ncol(ppm_df)){
         lines(ppm_df[,each_cal], col=mycolours[each_cal], type="p")}
@@ -771,15 +855,30 @@
 dev.off()
 
 }else{
-  print("inputfile has no intensities > 0")
-dev.off()
+    print("inputfile has no intensities > 0")
+    dev.off()
 }
 
+## tabular output of spectra values
+
+#if $pixel_output:
+    print("pixel list")
+    pixel_df = Reduce(function(...) merge(..., by=c("x", "y"), all=T), spectrum_list)
+    write.table(pixel_df, file="$pixel_tabular_output", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t")
+#end if
+
+
+
     ]]></configfile>
     </configfiles>
     <inputs>
         <param name="infile" type="data" format="imzml,rdata,analyze75" label="Inputfile as imzML, Analyze7.5 or Cardinal MSImageSet saved as RData"
             help="Upload composite datatype imzml (ibd+imzML) or analyze75 (hdr+img+t2m) or regular upload .RData (Cardinal MSImageSet)"/>
+        <param name="accuracy" type="float" value="50" label="Only for processed imzML files: enter mass accuracy to which the m/z values will be binned" help="This should be set to the native accuracy of the mass spectrometer, if known"/>
+        <param name="units" display="radio" type="select" label="Only for processed imzML files: unit of the mass accuracy" help="either m/z or ppm">
+            <option value="mz" >mz</option>
+            <option value="ppm" selected="True" >ppm</option>
+        </param>
         <param name="filename" type="text" value="" optional="true" label="Title" help="will appear as header in the quality report, if nothing given input dataset name is used"/>
         <param name="calibrant_file" type="data" optional="true" format="tabular"
             label="File with internal calibrants" help="first column: m/z, second column: name (optional), tabular file"/>
@@ -793,16 +892,22 @@
             <param name="distance" value="0.25" type="float" label="M/z range" help="Plusminus m/z window added to input m/z. In both m/z ranges the maximum intensity is used to calculate the fold change"/>
             <param name="filenameratioplot" type="text" optional="true" label="Title" help="Optional title for fold change plot."/>
         </repeat>
+        <param name="pixel_output" type="boolean" display="radio" label="Tabular with spectra information" help="Values for each spectrum (pixel) in x-y grid images"/>
     </inputs>
     <outputs>
         <data format="pdf" name="plots" from_work_dir="qualitycontrol.pdf" label = "$infile.display_name QC_report"/>
+        <data format="tabular" name="pixel_tabular_output" label="$infile.display_name spectra information">
+            <filter>pixel_output</filter>
+        </data>
     </outputs>
     <tests>
-        <test>
+        <test expect_num_outputs="2">
             <param name="infile" value="" ftype="imzml">
-                <composite_data value="Example_Continuous.imzML" />
-                <composite_data value="Example_Continuous.ibd" />
+                <composite_data value="Example_Processed.imzML"/>
+                <composite_data value="Example_Processed.ibd"/>
             </param>
+            <param name="accuracy" value="200"/>
+            <param name="units" value="ppm"/>
             <param name="peptide_file" value="inputpeptides.txt"/>
             <param name="calibrant_file" value="inputcalibrantfile1.txt"/>
             <param name="plusminus_dalton" value="0.25"/>
@@ -814,9 +919,11 @@
                 <param name="distance" value="0.25"/>
                 <param name="filenameratioplot" value = "Ratio of mass1 (328.9) / mass2 (398.8)"/>
             </repeat>
+            <param name="pixel_output" value="True"/>
+            <output name="pixel_tabular_output" file="spectra_info_imzml.txt"/>
             <output name="plots" file="QC_imzml.pdf" compare="sim_size" delta="20000"/>
         </test>
-        <test>
+        <test expect_num_outputs="1">
             <param name="infile" value="" ftype="analyze75">
                 <composite_data value="Analyze75.hdr"/>
                 <composite_data value="Analyze75.img"/>
@@ -828,13 +935,15 @@
             <param name="filename" value="Testfile_analyze75"/>
             <output name="plots" file="QC_analyze75.pdf" compare="sim_size" delta="20000"/>
         </test>
-        <test>
+        <test expect_num_outputs="2">
             <param name="infile" value="123_combined.RData" ftype="rdata"/>
             <param name="plusminus_dalton" value="0.2"/>
             <param name="filename" value="Testfile_rdata"/>
+            <param name="pixel_output" value="True"/>
+            <output name="pixel_tabular_output" file="spectra_info_123_combi.txt"/>
             <output name="plots" file="QC_rdata.pdf" compare="sim_size" delta="20000"/>
         </test>
-        <test>
+        <test expect_num_outputs="1">
             <param name="infile" value="empty_spectra.rdata" ftype="rdata"/>
             <param name="peptide_file" value="inputpeptides.txt"/>
             <param name="calibrant_file" value="inputcalibrantfile2.txt"/>
@@ -864,6 +973,7 @@
 Output: 
 
 - quality control report as pdf with key numbers and descriptive plots describing the mass spectrometry imaging data
+- optional spectra information as tabular file with numbers of calibrants (needs input calibrant file), numbers of peaks, TIC and most abundant m/z in each spectrum
 
 Tip: 
 
Binary file test-data/Example_Continuous.ibd has changed
--- a/test-data/Example_Continuous.imzML	Mon Jun 11 17:34:19 2018 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,313 +0,0 @@
-<?xml version="1.0"?>
-<mzML version="1.1" 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_idx.xsd">
-	<cvList count="3">
-		<cv id="MS" fullName="Proteomics Standards Initiative Mass Spectrometry Ontology" version="1.3.1" URI="http://psidev.info/ms/mzML/psi-ms.obo" />
-		<cv id="UO" fullName="Unit Ontology" version="1.15" URI="http://obo.cvs.sourceforge.net/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" value="" />
-			<cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum" value="" />
-			<cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="{51BB7C6F-9974-4626-B35F-5B65547BAE6B}" />
-			<cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="26C26A63DCF7CD1AD768A67AEDB7131C5D88C397" />
-			<cvParam cvRef="IMS" accession="IMS:1000030" name="continuous" value="" />
-		</fileContent>
-	</fileDescription>
-	<referenceableParamGroupList count="4">
-		<referenceableParamGroup id="spectrum1">
-			<cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum" value="" />
-			<cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0" />
-			<cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum" value="" />
-		</referenceableParamGroup>
-		<referenceableParamGroup id="scan1">
-			<cvParam cvRef="MS" accession="MS:1000093" name="increasing m/z scan" value="" />
-			<cvParam cvRef="MS" accession="MS:1000095" name="linear" value="" />
-		</referenceableParamGroup>
-		<referenceableParamGroup id="mzArray">
-			<cvParam cvRef="MS" accession="MS:1000576" name="no compression" value="" />
-			<cvParam cvRef="MS" accession="MS:1000514" name="m/z array" value="" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z" />
-			<cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true" />
-			<cvParam cvRef="MS" accession="MS:1000521" name="32-bit float" value="32-bit float" />
-		</referenceableParamGroup>
-		<referenceableParamGroup id="intensityArray">
-			<cvParam cvRef="MS" accession="MS:1000576" name="no compression" value="" />
-			<cvParam cvRef="MS" accession="MS:1000515" name="intensity array" value="" unitCvRef="MS" unitAccession="MS:1000131" unitName="number of counts" />
-			<cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true" />
-			<cvParam cvRef="MS" accession="MS:1000521" name="32-bit float" value="32-bit float" />
-		</referenceableParamGroup>
-	</referenceableParamGroupList>
-	<sampleList count="1">
-		<sample id="sample1" name="Sample1">
-			<cvParam cvRef="MS" accession="MS:1000001" name="sample number" value="1" />
-		</sample>
-	</sampleList>
-	<softwareList count="1">
-		<software id="Cardinal" version="1.12.0">
-			<cvParam cvRef="MS" accession="MS:1000799" name="custom unreleased software tool" value="" />
-		</software>
-	</softwareList>
-	<scanSettingsList count="1">
-		<scanSettings id="scansettings1">
-			<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" />
-		</scanSettings>
-	</scanSettingsList>
-	<instrumentConfigurationList count="1">
-		<instrumentConfiguration id="IC1" />
-	</instrumentConfigurationList>
-	<dataProcessingList count="1">
-		<dataProcessing id="CardinalWriteImzML">
-			<processingMethod order="1" softwareRef="Cardinal">
-				<cvParam cvRef="MS" accession="MS:1000544" name="Conversion to mzML" value="" />
-			</processingMethod>
-		</dataProcessing>
-	</dataProcessingList>
-	<run defaultInstrumentConfigurationRef="IC1" id="Experiment01" sampleRef="sample1">
-		<spectrumList count="9" defaultDataProcessingRef="CardinalWriteImzML">
-			<spectrum id="Spectrum=1" defaultArrayLength="0" index="1">
-				<referenceableParamGroupRef ref="spectrum1" />
-				<scanList count="1">
-					<cvParam cvRef="MS" accession="MS:1000795" name="no combination" value="" />
-					<scan instrumentConfigurationRef="IC1">
-						<referenceableParamGroupRef ref="scan1" />
-						<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="4796" />
-						<binary />
-					</binaryDataArray>
-					<binaryDataArray encodedLength="0">
-						<referenceableParamGroupRef ref="intensityArray" />
-						<cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="4812" />
-						<cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199" />
-						<cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="4796" />
-						<binary />
-					</binaryDataArray>
-				</binaryDataArrayList>
-			</spectrum>
-			<spectrum id="Spectrum=2" defaultArrayLength="0" index="2">
-				<referenceableParamGroupRef ref="spectrum1" />
-				<scanList count="1">
-					<cvParam cvRef="MS" accession="MS:1000795" name="no combination" value="" />
-					<scan instrumentConfigurationRef="IC1">
-						<referenceableParamGroupRef ref="scan1" />
-						<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="4796" />
-						<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="4796" />
-						<binary />
-					</binaryDataArray>
-				</binaryDataArrayList>
-			</spectrum>
-			<spectrum id="Spectrum=3" defaultArrayLength="0" index="3">
-				<referenceableParamGroupRef ref="spectrum1" />
-				<scanList count="1">
-					<cvParam cvRef="MS" accession="MS:1000795" name="no combination" value="" />
-					<scan instrumentConfigurationRef="IC1">
-						<referenceableParamGroupRef ref="scan1" />
-						<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="4796" />
-						<binary />
-					</binaryDataArray>
-					<binaryDataArray encodedLength="0">
-						<referenceableParamGroupRef ref="intensityArray" />
-						<cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="14404" />
-						<cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199" />
-						<cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="4796" />
-						<binary />
-					</binaryDataArray>
-				</binaryDataArrayList>
-			</spectrum>
-			<spectrum id="Spectrum=4" defaultArrayLength="0" index="4">
-				<referenceableParamGroupRef ref="spectrum1" />
-				<scanList count="1">
-					<cvParam cvRef="MS" accession="MS:1000795" name="no combination" value="" />
-					<scan instrumentConfigurationRef="IC1">
-						<referenceableParamGroupRef ref="scan1" />
-						<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="4796" />
-						<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="4796" />
-						<binary />
-					</binaryDataArray>
-				</binaryDataArrayList>
-			</spectrum>
-			<spectrum id="Spectrum=5" defaultArrayLength="0" index="5">
-				<referenceableParamGroupRef ref="spectrum1" />
-				<scanList count="1">
-					<cvParam cvRef="MS" accession="MS:1000795" name="no combination" value="" />
-					<scan instrumentConfigurationRef="IC1">
-						<referenceableParamGroupRef ref="scan1" />
-						<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="4796" />
-						<binary />
-					</binaryDataArray>
-					<binaryDataArray encodedLength="0">
-						<referenceableParamGroupRef ref="intensityArray" />
-						<cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="23996" />
-						<cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199" />
-						<cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="4796" />
-						<binary />
-					</binaryDataArray>
-				</binaryDataArrayList>
-			</spectrum>
-			<spectrum id="Spectrum=6" defaultArrayLength="0" index="6">
-				<referenceableParamGroupRef ref="spectrum1" />
-				<scanList count="1">
-					<cvParam cvRef="MS" accession="MS:1000795" name="no combination" value="" />
-					<scan instrumentConfigurationRef="IC1">
-						<referenceableParamGroupRef ref="scan1" />
-						<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="4796" />
-						<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="4796" />
-						<binary />
-					</binaryDataArray>
-				</binaryDataArrayList>
-			</spectrum>
-			<spectrum id="Spectrum=7" defaultArrayLength="0" index="7">
-				<referenceableParamGroupRef ref="spectrum1" />
-				<scanList count="1">
-					<cvParam cvRef="MS" accession="MS:1000795" name="no combination" value="" />
-					<scan instrumentConfigurationRef="IC1">
-						<referenceableParamGroupRef ref="scan1" />
-						<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="4796" />
-						<binary />
-					</binaryDataArray>
-					<binaryDataArray encodedLength="0">
-						<referenceableParamGroupRef ref="intensityArray" />
-						<cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="33588" />
-						<cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199" />
-						<cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="4796" />
-						<binary />
-					</binaryDataArray>
-				</binaryDataArrayList>
-			</spectrum>
-			<spectrum id="Spectrum=8" defaultArrayLength="0" index="8">
-				<referenceableParamGroupRef ref="spectrum1" />
-				<scanList count="1">
-					<cvParam cvRef="MS" accession="MS:1000795" name="no combination" value="" />
-					<scan instrumentConfigurationRef="IC1">
-						<referenceableParamGroupRef ref="scan1" />
-						<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="4796" />
-						<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="4796" />
-						<binary />
-					</binaryDataArray>
-				</binaryDataArrayList>
-			</spectrum>
-			<spectrum id="Spectrum=9" defaultArrayLength="0" index="9">
-				<referenceableParamGroupRef ref="spectrum1" />
-				<scanList count="1">
-					<cvParam cvRef="MS" accession="MS:1000795" name="no combination" value="" />
-					<scan instrumentConfigurationRef="IC1">
-						<referenceableParamGroupRef ref="scan1" />
-						<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="4796" />
-						<binary />
-					</binaryDataArray>
-					<binaryDataArray encodedLength="0">
-						<referenceableParamGroupRef ref="intensityArray" />
-						<cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="43180" />
-						<cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="1199" />
-						<cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="4796" />
-						<binary />
-					</binaryDataArray>
-				</binaryDataArrayList>
-			</spectrum>
-		</spectrumList>
-	</run>
-</mzML>
Binary file test-data/Example_Processed.ibd has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/Example_Processed.imzML	Tue Jun 19 18:08:15 2018 -0400
@@ -0,0 +1,373 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<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_idx.xsd" version="1.1">
+  <cvList count="3">
+    <cv id="MS" fullName="Proteomics Standards Initiative Mass Spectrometry Ontology" version="1.3.1" URI="http://psidev.info/ms/mzML/psi-ms.obo"/>
+    <cv id="UO" fullName="Unit Ontology" version="1.15" URI="http://obo.cvs.sourceforge.net/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" value=""/>
+      <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum" value=""/>
+      <cvParam cvRef="IMS" accession="IMS:1000080" name="universally unique identifier" value="{9D501BDC-5344-4916-B7E9-7E795B02C856}"/>
+      <cvParam cvRef="IMS" accession="IMS:1000091" name="ibd SHA-1" value="7E8FDB93053915D3EDB51B70AA0619AC209964DF"/>
+      <cvParam cvRef="IMS" accession="IMS:1000031" name="processed" value=""/>
+    </fileContent>
+    <sourceFileList count="1">
+      <sourceFile id="sf1" name="Example.raw" location="C:\Users\Thorsten Schramm\Documents\Promotion\imzML\Website\files\Beispiel-Dateien\Example images\">
+        <cvParam cvRef="MS" accession="MS:1000563" name="Thermo RAW file" value=""/>
+        <cvParam cvRef="MS" accession="MS:1000768" name="Thermo nativeID format" value=""/>
+        <cvParam cvRef="MS" accession="MS:1000569" name="SHA-1" value="7623BE263B25FF99FDF017154B86FAB742D4BB0B"/>
+      </sourceFile>
+    </sourceFileList>
+    <contact>
+      <cvParam cvRef="MS" accession="MS:1000586" name="contact name" value="Thorsten Schramm"/>
+      <cvParam cvRef="MS" accession="MS:1000590" name="contact organization" value="Institut für Anorganische und Analytische Chemie"/>
+      <cvParam cvRef="MS" accession="MS:1000587" name="contact address" value="Schubertstraße 60, Haus 16, Gießen, Germany"/>
+      <cvParam cvRef="MS" accession="MS:1000589" name="contact email" value="thorsten.schramm@anorg.chemie.uni-.giessen.de"/>
+    </contact>
+  </fileDescription>
+  <referenceableParamGroupList count="4">
+    <referenceableParamGroup id="mzArray">
+      <cvParam cvRef="MS" accession="MS:1000576" name="no compression" value=""/>
+      <cvParam cvRef="MS" accession="MS:1000514" name="m/z array" value="" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+      <cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true"/>
+      <cvParam cvRef="MS" accession="MS:1000521" name="32-bit float" value=""/>
+    </referenceableParamGroup>
+    <referenceableParamGroup id="intensityArray">
+      <cvParam cvRef="MS" accession="MS:1000576" name="no compression" value=""/>
+      <cvParam cvRef="MS" accession="MS:1000515" name="intensity array" value="" unitCvRef="MS" unitAccession="MS:1000131" unitName="number of counts"/>
+      <cvParam cvRef="IMS" accession="IMS:1000101" name="external data" value="true"/>
+      <cvParam cvRef="MS" accession="MS:1000521" name="32-bit float" value=""/>
+    </referenceableParamGroup>
+    <referenceableParamGroup id="scan1">
+      <cvParam cvRef="MS" accession="MS:1000093" name="increasing m/z scan" value=""/>
+      <cvParam cvRef="MS" accession="MS:1000095" name="linear" value=""/>
+      <cvParam cvRef="MS" accession="MS:1000512" name="filter string" value="ITMS - p NSI Full ms [100,00-800,00]"/>
+    </referenceableParamGroup>
+    <referenceableParamGroup id="spectrum1">
+      <cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum" value=""/>
+      <cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="0"/>
+      <cvParam cvRef="MS" accession="MS:1000128" name="profile spectrum" value=""/>
+      <cvParam cvRef="MS" accession="MS:1000129" name="negative scan" value=""/>
+    </referenceableParamGroup>
+  </referenceableParamGroupList>
+  <sampleList count="1">
+    <sample id="sample1" name="Sample1">
+      <cvParam cvRef="MS" accession="MS:1000001" name="sample number" value="1"/>
+    </sample>
+  </sampleList>
+  <softwareList count="2">
+    <software id="Xcalibur" version="2.2">
+      <cvParam cvRef="MS" accession="MS:1000532" name="Xcalibur" value=""/>
+    </software>
+    <software id="TMC" version="1.1 beta">
+      <cvParam cvRef="MS" accession="MS:1000799" name="custom unreleased software tool" value=""/>
+    </software>
+  </softwareList>
+  <scanSettingsList count="1">
+    <scanSettings id="scansettings1">
+      <cvParam cvRef="IMS" accession="IMS:1000401" name="top down" value=""/>
+      <cvParam cvRef="IMS" accession="IMS:1000413" name="flyback" value=""/>
+      <cvParam cvRef="IMS" accession="IMS:1000480" name="horizontal line scan" value=""/>
+      <cvParam cvRef="IMS" accession="IMS:1000491" name="linescan left right" value=""/>
+      <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"/>
+      <cvParam cvRef="MS" accession="MS:1000836" name="dried dropplet" value=""/>
+      <cvParam cvRef="MS" accession="MS:1000835" name="matrix solution concentration" value="10"/>
+      <cvParam cvRef="MS" accession="MS:1000834" name="matrix solution" value="DHB"/>
+    </scanSettings>
+  </scanSettingsList>
+  <instrumentConfigurationList count="1">
+    <instrumentConfiguration id="LTQFTUltra0">
+      <cvParam cvRef="MS" accession="MS:1000557" name="LTQ FT Ultra" value=""/>
+      <cvParam cvRef="MS" accession="MS:1000529" name="instrument serial number" value="none"/>
+      <componentList count="3">
+        <source order="1">
+          <cvParam cvRef="MS" accession="MS:1000073" name="electrospray ionization" value=""/>
+          <cvParam cvRef="MS" accession="MS:1000485" name="nanospray inlet" value=""/>
+          <cvParam cvRef="MS" accession="MS:1000843" name="wavelength" value="337"/>
+          <cvParam cvRef="MS" accession="MS:1000844" name="focus diameter x" value="10"/>
+          <cvParam cvRef="MS" accession="MS:1000845" name="focus diameter y" value="10"/>
+          <cvParam cvRef="MS" accession="MS:1000846" name="pulse energy" value="10"/>
+          <cvParam cvRef="MS" accession="MS:1000847" name="pulse duration" value="10"/>
+          <cvParam cvRef="MS" accession="MS:1000848" name="attenuation" value="50"/>
+          <cvParam cvRef="MS" accession="MS:1000850" name="gas laser" value=""/>
+          <cvParam cvRef="IMS" accession="IMS:1000202" name="target material" value="Conductive Glas"/>
+        </source>
+        <analyzer order="2">
+          <cvParam cvRef="MS" accession="MS:1000264" name="ion trap" value=""/>
+          <cvParam cvRef="MS" accession="MS:1000014" name="accuracy" value="0" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
+        </analyzer>
+        <detector order="3">
+          <cvParam cvRef="MS" accession="MS:1000253" name="electron multiplier" value=""/>
+          <cvParam cvRef="MS" accession="MS:1000120" name="transient recorder" value=""/>
+        </detector>
+      </componentList>
+      <softwareRef ref="Xcalibur"/>
+    </instrumentConfiguration>
+  </instrumentConfigurationList>
+  <dataProcessingList count="2">
+    <dataProcessing id="XcaliburProcessing">
+      <processingMethod order="1" softwareRef="Xcalibur">
+        <cvParam cvRef="MS" accession="MS:1000594" name="low intensity data point removal" value=""/>
+      </processingMethod>
+    </dataProcessing>
+    <dataProcessing id="TMCConversion">
+      <processingMethod order="2" softwareRef="TMC">
+        <cvParam cvRef="MS" accession="MS:1000544" name="Conversion to mzML" value=""/>
+      </processingMethod>
+    </dataProcessing>
+  </dataProcessingList>
+  <run defaultInstrumentConfigurationRef="LTQFTUltra0" defaultSourceFileRef="sf1" id="Experiment01" sampleRef="sample1" startTimeStamp="2009-08-11T15:59:44">
+    <spectrumList count="9" defaultDataProcessingRef="XcaliburProcessing">
+      <spectrum id="Scan=1" defaultArrayLength="0" index="0">
+        <referenceableParamGroupRef ref="spectrum1"/>
+        <scanList count="1">
+          <cvParam cvRef="MS" accession="MS:1000795" name="no combination" value=""/>
+          <scan instrumentConfigurationRef="LTQFTUltra0">
+            <referenceableParamGroupRef ref="scan1"/>
+            <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:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="16"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+          <binaryDataArray encodedLength="0">
+            <referenceableParamGroupRef ref="intensityArray"/>
+            <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="33612"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+        </binaryDataArrayList>
+      </spectrum>
+      <spectrum id="Scan=2" defaultArrayLength="0" index="1">
+        <referenceableParamGroupRef ref="spectrum1"/>
+        <scanList count="1">
+          <cvParam cvRef="MS" accession="MS:1000795" name="no combination" value=""/>
+          <scan instrumentConfigurationRef="LTQFTUltra0">
+            <referenceableParamGroupRef ref="scan1"/>
+            <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:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="67208"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+          <binaryDataArray encodedLength="0">
+            <referenceableParamGroupRef ref="intensityArray"/>
+            <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="100804"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+        </binaryDataArrayList>
+      </spectrum>
+      <spectrum id="Scan=3" defaultArrayLength="0" index="2">
+        <referenceableParamGroupRef ref="spectrum1"/>
+        <scanList count="1">
+          <cvParam cvRef="MS" accession="MS:1000795" name="no combination" value=""/>
+          <scan instrumentConfigurationRef="LTQFTUltra0">
+            <referenceableParamGroupRef ref="scan1"/>
+            <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:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="134400"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+          <binaryDataArray encodedLength="0">
+            <referenceableParamGroupRef ref="intensityArray"/>
+            <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="167996"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+        </binaryDataArrayList>
+      </spectrum>
+      <spectrum id="Scan=4" defaultArrayLength="0" index="3">
+        <referenceableParamGroupRef ref="spectrum1"/>
+        <scanList count="1">
+          <cvParam cvRef="MS" accession="MS:1000795" name="no combination" value=""/>
+          <scan instrumentConfigurationRef="LTQFTUltra0">
+            <referenceableParamGroupRef ref="scan1"/>
+            <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:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="201592"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+          <binaryDataArray encodedLength="0">
+            <referenceableParamGroupRef ref="intensityArray"/>
+            <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="235188"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+        </binaryDataArrayList>
+      </spectrum>
+      <spectrum id="Scan=5" defaultArrayLength="0" index="4">
+        <referenceableParamGroupRef ref="spectrum1"/>
+        <scanList count="1">
+          <cvParam cvRef="MS" accession="MS:1000795" name="no combination" value=""/>
+          <scan instrumentConfigurationRef="LTQFTUltra0">
+            <referenceableParamGroupRef ref="scan1"/>
+            <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:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="268784"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+          <binaryDataArray encodedLength="0">
+            <referenceableParamGroupRef ref="intensityArray"/>
+            <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="302380"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+        </binaryDataArrayList>
+      </spectrum>
+      <spectrum id="Scan=6" defaultArrayLength="0" index="5">
+        <referenceableParamGroupRef ref="spectrum1"/>
+        <scanList count="1">
+          <cvParam cvRef="MS" accession="MS:1000795" name="no combination" value=""/>
+          <scan instrumentConfigurationRef="LTQFTUltra0">
+            <referenceableParamGroupRef ref="scan1"/>
+            <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:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="335976"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+          <binaryDataArray encodedLength="0">
+            <referenceableParamGroupRef ref="intensityArray"/>
+            <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="369572"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+        </binaryDataArrayList>
+      </spectrum>
+      <spectrum id="Scan=7" defaultArrayLength="0" index="6">
+        <referenceableParamGroupRef ref="spectrum1"/>
+        <scanList count="1">
+          <cvParam cvRef="MS" accession="MS:1000795" name="no combination" value=""/>
+          <scan instrumentConfigurationRef="LTQFTUltra0">
+            <referenceableParamGroupRef ref="scan1"/>
+            <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:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="403168"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+          <binaryDataArray encodedLength="0">
+            <referenceableParamGroupRef ref="intensityArray"/>
+            <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="436764"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+        </binaryDataArrayList>
+      </spectrum>
+      <spectrum id="Scan=8" defaultArrayLength="0" index="7">
+        <referenceableParamGroupRef ref="spectrum1"/>
+        <scanList count="1">
+          <cvParam cvRef="MS" accession="MS:1000795" name="no combination" value=""/>
+          <scan instrumentConfigurationRef="LTQFTUltra0">
+            <referenceableParamGroupRef ref="scan1"/>
+            <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:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="470360"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+          <binaryDataArray encodedLength="0">
+            <referenceableParamGroupRef ref="intensityArray"/>
+            <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="503956"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+        </binaryDataArrayList>
+      </spectrum>
+      <spectrum id="Scan=9" defaultArrayLength="0" index="8">
+        <referenceableParamGroupRef ref="spectrum1"/>
+        <scanList count="1">
+          <cvParam cvRef="MS" accession="MS:1000795" name="no combination" value=""/>
+          <scan instrumentConfigurationRef="LTQFTUltra0">
+            <referenceableParamGroupRef ref="scan1"/>
+            <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:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="537552"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+          <binaryDataArray encodedLength="0">
+            <referenceableParamGroupRef ref="intensityArray"/>
+            <cvParam cvRef="IMS" accession="IMS:1000103" name="external array length" value="8399"/>
+            <cvParam cvRef="IMS" accession="IMS:1000102" name="external offset" value="571148"/>
+            <cvParam cvRef="IMS" accession="IMS:1000104" name="external encoded length" value="33596"/>
+            <binary/>
+          </binaryDataArray>
+        </binaryDataArrayList>
+      </spectrum>
+    </spectrumList>
+  </run>
+</mzML>
\ No newline at end of file
Binary file test-data/QC_analyze75.pdf has changed
Binary file test-data/QC_empty_spectra.pdf has changed
Binary file test-data/QC_imzml.pdf has changed
Binary file test-data/QC_rdata.pdf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/spectra_info_123_combi.txt	Tue Jun 19 18:08:15 2018 -0400
@@ -0,0 +1,13 @@
+	x	y	Number of Peaks	TIC per spectrum	Most abundant m/z
+1	1	1	1798	121.850390398685	152.91667175293
+2	1	2	2836	200.963327709254	153.08332824707
+3	1	3	2405	127.846644478468	153.16667175293
+4	3	1	2810	182.318354201019	153.08332824707
+5	3	2	2540	135.305841731585	328.916687011719
+6	3	3	2812	168.270181475225	153
+7	4	1	2844	161.809190448268	153
+8	4	2	2157	108.395974184216	171.25
+9	4	3	3168	243.539506603108	153.08332824707
+10	9	1	2844	161.809190448268	153
+11	9	2	2157	108.395974184216	171.25
+12	9	3	3168	243.539506603108	153.08332824707
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/spectra_info_imzml.txt	Tue Jun 19 18:08:15 2018 -0400
@@ -0,0 +1,10 @@
+	x	y	Number of Calibrants	Number of Peaks	TIC per spectrum	Most abundant m/z
+1	1	1	1	1364	121.850390398685	328.971197672656
+2	1	2	2	1961	200.963327709254	328.971197672656
+3	1	3	2	1714	127.846644478468	153.173335465757
+4	2	1	1	1986	182.318354201019	153.112078382987
+5	2	2	0	1801	135.305841731585	328.971197672656
+6	2	3	0	1968	168.270181475225	255.28235280251
+7	3	1	1	1974	161.809190448268	152.989637701451
+8	3	2	0	1505	108.395974184216	255.28235280251
+9	3	3	1	2180	243.539506603108	153.112078382987