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] Creating a new data representation. #32

Closed inesboxexa closed 4 years ago

inesboxexa commented 4 years ago

Hi Alan,

I believe this is still related with the changes made to SA recently.

In my function to save a datacube (from a lists of peak details), I have now the following code:

reduction = DatacubeReduction(peakTolerance, toleranceUnit, output, intensityDataType, storageType);

    addlistener(reduction, 'FastMethods', @(src, canUseFastMethods)disp(['! Using fast Methods?   ' num2str(canUseFastMethods.bool)]));

    peakList.minSpectralChannel = [ datacubeonly_peakDetails(:,1) ];
    peakList.centroid = [ datacubeonly_peakDetails(:,2) ];
    peakList.maxSpectralChannel = [ datacubeonly_peakDetails(:,3) ];

    reduction.setPeakList(peakList);

    datacube = reduction.process(data);
    datacube = datacube.get(1);
    datacube = datacube.saveobj();

Which however doesnt seem to work. I got the following error:

Assignment has more non-singleton rhs dimensions than non-singleton subscripts

Error in DatacubeReduction/processOtherParser (line 247) data{pixelListIndex}(row, :) = images(i, :);

Error in DatacubeReduction/process (line 51) dataRepresentationList = this.processOtherParser(dataRepresentation);

Error in f_saving_data_cube (line 47) datacube = reduction.process(data);

Let me know what you think it could be.

Thanks, Teresa

AlanRace commented 4 years ago

Hi Teresa, Are you sure that you have the latest version downloaded? I believe this bug was fixed in commit b1624cf8056348bbdb97a4a92780a91a25f05c6b (roughly 4 days ago).

Can you confirm that this is still an issue with the latest version?

Thanks,

Alan

inesboxexa commented 4 years ago

Hi Alan,

I just got the most recent version, but using it didnt solve the issue. I'm still getting the erro:

Assignment has more non-singleton rhs dimensions than non-singleton subscripts

Error in DatacubeReduction/processOtherParser (line 246) data{pixelListIndex}(row, :) = images(col, :);

Error in DatacubeReduction/process (line 51) dataRepresentationList = this.processOtherParser(dataRepresentation);

Error in f_saving_data_cube (line 47) datacube = reduction.process(data);

Could it be that:

peakList.minSpectralChannel = [ datacubeonly_peakDetails(:,1) ]; peakList.centroid = [ datacubeonly_peakDetails(:,2) ]; peakList.maxSpectralChannel = [ datacubeonly_peakDetails(:,3) ];

reduction.setPeakList(peakList);

Is not appropriate? Maybe I'm missing to define something? (in addition to the PeakList)

Thanks, Teresa

AlanRace commented 4 years ago

I think it could be. peakList should be an array of Peak instances. This should create a proper peakList

peakList = [];

% This is where the peaks came from
originalSpectrum = SpectralData(mzs, counts);

for i = 1:size(datacubeonly_peakDetails, 1)
     % Peak takes the following arguments: spectralData, centroid, intensity, minSpectralChannel, maxSpectralChannel
     peak = Peak(originalSpectrum, datacubeonly_peakDetails(i, 2), datacubeonly_peakDetails(i, 4), datacubeonly_peakDetails(i,1), datacubeonly_peakDetails(i, 3));

     % Make a vector of Peak instances. If the list is empty then we need to initiate it with the peak, otherwise add peak to end of list
     if isempty(peakList)
         peakList = peak;
     else
         peakList(i) = peak;
     end
end
inesboxexa commented 4 years ago

Hi Alan,

Thank you very much! It worked!

Teresa

From: Alan Race notifications@github.com Sent: 04 August 2020 15:20 To: AlanRace/SpectralAnalysis SpectralAnalysis@noreply.github.com Cc: Teresa Murta teresa.murta@npl.co.uk; Author author@noreply.github.com Subject: [EXTERNAL] Re: [AlanRace/SpectralAnalysis] [ISSUE] Creating a new data representation. (#32)

CAUTION: This email originated from outside of NPL. Do not click links or open attachments unless you recognize the sender and know the content is safe.

I think it could be. peakList should be an array of Peak instances. This should create a proper peakList

peakList = [];

% This is where the peaks came from

originalSpectrum = SpectralData(mzs, counts);

for i = 1:size(datacubeonly_peakDetails, 1)

 % Peak takes the following arguments: spectralData, centroid, intensity, minSpectralChannel, maxSpectralChannel

 peak = Peak(originalSpectrum, datacubeonly_peakDetails(i, 2), datacubeonly_peakDetails(i, 4), datacubeonly_peakDetails(i,1), datacubeonly_peakDetails(i, 3));

 % Make a vector of Peak instances. If the list is empty then we need to initiate it with the peak, otherwise add peak to end of list

 if isempty(peakList)

     peakList = peak;

 else

     peakList(i) = peak;

 end

end

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/AlanRace/SpectralAnalysis/issues/32#issuecomment-668624880, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJCQ7MGD3XJCD7SN4BNZ2ZLR7AKIPANCNFSM4PUJBI5Q.

Visit the NPL websitehttps://www.npl.co.uk/ and find out how our cutting-edge measurement science has a positive impact in the real world.


[http://resource.npl.co.uk/images/npl-logo.jpg]http://www.npl.co.uk/?utm_source=Email%20Footer&utm_medium=email&utm_campaign=Homepage Keep in touchhttp://www.npl.co.uk/contact [http://resource.npl.co.uk/images/twitter.jpg] http://www.twitter.com/npl [http://resource.npl.co.uk/images/facebook.jpg] http://www.facebook.com/npldigital [http://resource.npl.co.uk/images/youtube.jpg] http://www.youtube.com/npldigital


NPL Privacy Policyhttp://www.npl.co.uk/privacy-policy/

If you have received this message in error, please notify us and remove it from your system. NPL Management Ltd cannot guarantee that the e-mail or any attachments are free from viruses.

NPL Management Ltd is a company registered in England and Wales, number: 2937881 Registered office: National Physical Laboratory | Hampton Road | Teddington, Middlesex | UK | TW11 0LW