AlanRace / SpectralAnalysis

Software for the analysis and interactive exploration of spectral imaging data
https://alanrace.github.io/SpectralAnalysis/
Apache License 2.0
29 stars 9 forks source link

[issue] with total spectrum generation #46

Open inesboxexa opened 3 years ago

inesboxexa commented 3 years ago

Hi Alan,

I have been using the code below to create a total spectra for a specific mask (saved in the roi variable) that I load but it doesnt seem to be working, ie, no matter what the roi mask looks like in the roi variable, the resulting total spectrum is the exactly the same.

Could the 2 commands: spectrumGeneration.processEntireDataset(false); spectrumGeneration.setRegionOfInterestList(roiList); not be doing what I think they were doing (ie changing the mask used to generate the spectra)?

Any help would be much apreaciated!

Thank you, Teresa

"
addJARsToClassPath() preprocessing = PreprocessingWorkflow; preprocessing.loadWorkflow(preprocessing_file);

    parser = ImzMLParser([imzml_file_complete_path]);
    parser.parse; % parse the imzML file

    spectrumGeneration = TotalSpectrum();
    spectrumGeneration.setPreprocessingWorkflow(preprocessing); % setting preprocessing workflow

    % Data reduction based on pixels of interest (defined as a binary mask)

    data = DataOnDisk(parser);

    pixels_num = sum(sum(data.regionOfInterest.pixelSelection));

    if ~isequal(mask_type,"no mask")

        load([ rois_path '\roi' ]) % loading region of interest

        roiList = RegionOfInterestList;
        roiList.add(roi);
        spectrumGeneration.processEntireDataset(false);
        spectrumGeneration.setRegionOfInterestList(roiList);

        pixels_num = sum(sum(roi.pixelSelection));

    end

    % Computing total spectrum

    totalSpectrum = spectrumGeneration.process(data);
    totalSpectrum = totalSpectrum.get(1);

    totalSpectrum_mzvalues      = totalSpectrum.spectralChannels;
    totalSpectrum_intensities   = totalSpectrum.intensities;