chromatography icon indicating copy to clipboard operation
chromatography copied to clipboard

[Don't merge] Octave-compatible changes

Open ghost opened this issue 6 years ago • 1 comments

Hello James,

as per your request, here are the changes I made to make your ImportAgilent.m code compatible with Octave 4.0.1 (as it is shipped with Debian 9.2). I thought that a git diff would be a much better way to show the changes, that's why I made a pull request. I don't expect you to merge these changes, especially since they break the inputParser, but it is much more comprehensible that way.

I also added comments explaining the reasons why I had to made that particular change, but for simplicity's sake, here is a summary:

  • addParameter (method of inputParser) does not exist in Octave (Version 4.0.1). Here is the corresponding issue. It looks like they have some patches available, but I was not sure about that. Also, I did not need the functionality and it was easier for me to just short-circuit it. I don't know if there's an alternative for that
  • In Octave, you use javaObject('fully.qualified.class.name', args...) to initialise a Java object. It seems like this functionality is also available in MATLAB - at least I found a source/documentation where they explicitly mention MATLAB
  • The Java package com.mathworks.* obviously doesn't exist in Octave, but the functionality you want is implemented in the native Java libraries, namely Swing. Initially I just dropped the filter code, because I just picked the .CH files and that's it, but I really think that this is more elegant since it uses native libraries instead of some MATLAB façade.

Now that I am writing this PR I see that I didn't properly change line 349:

fc = javax.swing.JFileChooser(java.io.File(pwd));

To exactly replicate the behaviour, you'd need to do it like that: (may not work, that's from the top of my head)

fcParam = javaObject('java.io.File', pwd);
fc = javaObject('javax.swing.JFileChooser', fcParam);

I am aware of the fact that the javaObject syntax is not as pretty as writing the fully qualified class name like it would be Java-native, but at least it works in Octave as well.

Please let me know if there's anything I can help you with.

Greetings, Chris

ghost avatar Dec 16 '17 19:12 ghost

I now added the Python plot script and an example CSV data file. The data was generated with your code, namely ImportAgilent.m and ExportCSV.m.

data = ImportAgilent()
% Then I chose the .CH file in the file choser
ExportCSV(data.time, data.intensity, 'file', 'hplc-out.csv')
% Please note that I used data.time and data.intensity, regarding your last message. 
% So it should already be corrected (corrected_signal = raw_signal * slope + intercept).
% Data.time was returned in [min], but as you later corrected me, it is expected to be
% in [s] for the peak area calculation. Therefore there's an `* 60` in the Python plot script

However, the file name last parameter did not work correctly. the file was always named data.CSV. I am not entirely sure, but I think I accidentally downloaded ExportCSV.m from master, while ImportAgilent.m was from dev. However, it worked, I just renamed the file and that's it. Please let me know if you also want to take a look at the original .CH files - I cannot add them publicly because they contain personal information, but I can supply them via email.

Greetings, Chris

PS.: To execute the Python script, use a Terminal/CMD (depending on your OS) and go into the directory where the .CSV example file is located. Then run python plot.py. You need to have Python, and the Python-libraries installed for it to work, namely matplotlib and scipy. (I used Python 3.5, but Python 2.7 should work, too, I think...)

ghost avatar Dec 16 '17 19:12 ghost