Closed neurofractal closed 2 years ago
Various issues to solve:
1 is a bug that can be fixed by downloading the latest version of SPM (I think?).
2 should be easy but needs implementing
3: Solved
Also something to check in future: FT to SPM conversion has been modified by using:
datafile = file_array(fullfile(D.path, fnamedat), [Nchannels Nsamples], ‘float64-le’);
and on the extra point why the modification for 'float64-le'? The OPM data only has 16-20 bits of precision. 64-bit seems like overkill unless there is a good reason.
Hey @tierneytim - cheers 👍.
and on the extra point why the modification for 'float64-le'? The OPM data only has 16-20 bits of precision. 64-bit seems like overkill unless there is a good reason.
So I ran into problems when downsampling the data in FT (to 600Hz) before passing onto SPM. Any ideas? I shall investigate further...
On precision, this is most likely a problem with the resampler and not the data. Therefore keep the data as 32-bit. I would also strongly advise against using the default resampler as it is inappropriate for our OPM data. I've nearly finished writing a generic downsampler that is more suitable for our needs and so this problem will vanish soon enough. If you really need to use it, just use the spm_eeg_downsample and then convert to fieldtrip. Then if you still have bugs report to myself/Vladimir.
@neurofractal am I right in thinking that the errors you describe come from comparing the FT object after downsampling with the SPM object when you use a ft2spm function? As I think the downsampler is the red herring here.
@georgeoneill don't think so:
FT --> SPM --> FT the data is identical before and after Downsample --> FT --> SPM --> FT the data is not identical before and after
by 'data' you mean the raw field values?
what do you mean by identical? what is your tolerance here for identical? what datasets are being compared for equality? by how much do they differ?
Okay I think I understand the problem. Can you check the data types before and after the downsampling?
Yeah, I think fieldtrip is doing a cast to double so hopefully the error is just the difference between single and double precision...
I agree. Which would explain why setting the file array datatype to double means you are no loger getting 'data' errors. I think @tierneytim's advice of trying to downsample in SPM rather than fieldtrip (which should respect datatypes) is a reasonable stopgap for the time being, as hard-coding SPM to always cast to double going forward might cause more headaches later.
Thanks both - sounds like a plan. @tierneytim when you get the downsampler working please do let me know :)
@neurofractal, I don't think the downsampling should be included in the mfc wrapper. They should be two separate stages in an analysis script (if it is to be used at all). The mean-field correction should run very quickly on any dataset. The user can specify the maximum memory usage so downsampling should not be necessary. Unless you have a reason for this?
Also, spm_eeg_downsample should have the trigNN flag set to 1 if it is used on OPM data
Also, spm_eeg_downsample should have the trigNN flag set to 1 if it is used on OPM data
Aah thanks 👍
Unless you have a reason for this?
Not particularly, other than saving me time when messing about with data. I'm not going to spend too long on making this perfect, given we will make a fully FT version of the code when the SPM version is stable.
I'm curious, how much time is saved for spm_opm_mfc? For me, it's always faster to directly run it rather then downsample and run.
https://github.com/tierneytim/OPM/blob/master/spm_opm_mfc.m