Currently, the analysis available are:
Plain ol' FFT
However, new analysis will be added in the future. Also, you won't find here the theory behind these methods, you can browse the internet about the FFT , and the S-Transform .
You have to first run the analysis, which generates new files,
and then open those files to see the results. This part only refers
to the analysis itself, the other part is
how
to work with the display
.
* see article Intracerebral dipole source localization for FFT power maps by D. Lehman and C.M. Michel, in Electroencephalography and clinical Neurophysiology, 1990, Elsevier.
Call the dialog from Tools | Frequency Analysis menu, which is context sensitive:
Called from an EEG file, the analysis will apply only to this very current file.
In any other case, the dialog will operate in Batch mode, requiring you to later select some files.
The following dialog pops out. Fill the parameters which are relevant for you, then click either on Process Current or Batch Process (according to how the dialog was invoked):
Presets: |
The most used sets of parameters, which make use of either FFT's or of S-Transform. Presets can be found either for surface or intra-cranial recordings, for the Power Maps and FFT Approximation, and for all these cases, with variations using a STFT (more time resolution). There are also presets for the Wavelet S-Transform.
The most important parameters will be set, still some parameters have to be set manually! And, as usual, double check that all your settings make sense... |
Tracks to Analyse |
|
Tracks to analyse |
From an opened EEG:
In Batch Mode: You can of course modify this list. See important note about notation . |
Names from XYZ: |
Optionally pointing to a file with the electrodes coordinates and
names (such as .els and .xyz).
The names of the electrodes are taken from this file,
overriding the original names from the EEG (i.e. you can rename the electrodes). Constraints as in the link mechanism must be respected, such as same number of electrodes, same order, etc... |
Time Windows |
|
Analyse From [TF]: |
First time frame to be analysed, |
to |
and last time frame required for analysis. |
(... after clipping) |
For info, the last time frame to be actually analysed, with current parameters. This number might slightly differ from the previous field due to the subdivision in time windows. |
End of File |
Automatically set the last time frame to the actual end of the current file . Useful in Batch Mode, if the files have different lengths. |
Windows Size: |
For an FFT analysis, data is analyzed by blocks, aka time windows:
For the S-Transform, there is only one single big window which is the full time range to be analyzed. See this note about time frequency issues. |
Windows Step: |
How much stepping to do when fetching the next time window:
Note that a 1 TF step is equivalent to perform a Short Term Fourier Transform (STFT) . A 25% step (BTW used to be 75% overlap) is a safe way to add significantly new data to the time window. A 100% step is useful in case you have epochs pasted into a single file, and you shouldn't mix their data. So setting the window size to the epoch length, and stepping 100% is the way to go. |
windows step ... [ms] |
Showing the resulting step in [ms] between successive time windows. |
Number of Window(s): |
Showing the number of time windows you get with the current parameters. If the S-Transform analysis is used, there is only 1 window which extends exactly on the time range selected above. |
|
|
Sampling Frequency: |
The current sampling frequency, if available from the current file. If in Batch mode, however, this field can and should be filled by hand. |
Frequency Range and Resolution: |
The range of frequencies and the frequency step/resolution you can obtain with your current parameters (Sampling Frequency and Window Size). For example, if step is 0.5 Hz, frequencies actually available will be: 0, 0.5, 1, 1.5 etc... Hz. |
Specify a single interval of frequencies to be saved in the output file. Give the lowest and the highest frequencies of the interval, plus a step/resolution. The saved frequency steps can be bigger than the minimum available, f.ex. you can save by steps of 1 Hz even if the analysis offers you a 0.5 Hz resolution. In this case Cartool will average neighboring frequencies , therefore increasing the signal to noise ratio.
Remember that it is always a good idea to constrain the saved frequency range to be as small as possible according to your data. Otherwise you will have bigger and slower files, and for no use. |
|
Log Frequencies: |
Frequencies are inherently logarithmic by nature. For small ranges of frequencies, or to comply with usages, the whole interval of frequencies is often used. But for more accurate, or for broader ranges of frequencies, it is highly recommended to use a logarithmic scale instead. |
split into XX per Decade |
This tells how many subdivisions to save per decades (frequencies multipled by 10). F.ex. 20 values per decade means:
|
Saving Frequency Bands: |
Save any number of bands, computing the average for each of them. Give the list of bands, separated either by a space, a comma or semi-colon. Be careful to actually order the bands: Cartool will follow the exact sequence you specify, so keep things consistant by using increasing frequency bands! F.ex.: 0-4, 4-8, 8-12, 12-20 See this note about averaging frequencies. |
Type of Analysis |
You can choose between 3 well proven and robust analysis:
|
|
The classical FFT, or the STFT (Short Term Fourier Transform) if the Windows Step parameter is set to 1 TF. With Average Reference data and saving the Square Norm, you can compute the Power Maps on surface recordings (see the Presets). |
|
Projection on the least-square deviation line going through the FFT for each window (of the average-referenced data), aka best dipole fitting. Results are in the "real" values, and will look like an EEG with polarity (see the Presets). See this note about averaging FFT approximation. |
|
The Stockwell Transform allows for some optimal time and frequency resolution. Note that it applies only to a single window, which can be as big as needed by your analysis. However to reduce the computational cost, and for big ranges, use rather the plain FFT and keep the S-Transform for shorter time ranges (like a magnifier on a given area). |
FFT Windowing Function: |
|
None |
No windowing function added (or, to be totally precise, using a Flat Top windowing function). |
Hanning |
Hanning windowing function. Try this to learn more. Also see this technical point. Recommended most of the time, except if you have no overlap between windows, or a a single time window. |
|
|
Averaged |
Analysed windows are averaged, hence the result will be a single "Time Point". See this note about the averaging. |
in Sequence |
Analysed windows are written sequentially, so you can have an idea of the frequencies in time. See this note about the time reference. |
FFT Time Windows Rescaling: |
The FFT formula includes specifies a normalization, or divisive factor. Problem is there is no agreement on which formula to use in practice. Here you can specify the one to your liking:
Note: this option is relevant only for single forward FFT's, and not for the S-Transform (which is a forward + backward FFT all in one!) |
Outputting Values: |
Results of the analysis are always complex values. Usage is to save only the norm or power of these complex values, but you can still control what to actually save according to your needs:
|
Reference of Data |
|
No Reference |
Use the same reference as when the file(s) was(were) written, that is, no change in reference. |
Use Current Reference |
Use the reference currently in use. Useful only if the files have already been opened in Cartool, and the user has changed the reference. |
Average Reference |
Use the average reference, overriding current reference. |
Other Reference |
Use the average of the specified list of electrodes. If only one electrode is specified, this will be the reference. |
|
|
Optional filename infix override: |
The saved filenames will have the specified characters inserted. Default is a combination of the type of analysis and frequency range, which can be long and clumsy for your use. |
All Results in Single freq File |
This is the default ouput, a binary file holding all the results (frequencies, electrodes, and all time windows). Use this to save space on your disk, and / or to later use the Frequency Display of Cartool. |
All Results in a Sub-Directory |
Optionally saving all results in a sub-directory for a better organization. Kind of hand if you wish to split the data with the splitting options below. |
Open File(s) Upon Completion |
...of the analysis. Just be careful in Batch Mode , this could open a lot of files! (the original EEG files are opened one at a time, then closed when done). |
Splitting Results: |
Frequency analysis results are 3D data by nature: electrodes x time x frequencies. To facilate either the display, the export or the processing with other toolboxes, it comes in handy to split these data into smalller, 2D files.
Note: You can always break down .freq files , or merge 2D files back into .freq files later on. |
|
Splitting results with one file per electrode. |
|
Splitting results with one file per frequency. |
|
Splitting results with one file per spectrum. If you process sequentially the different time windows, there will be as many output files as there are of these time windows. If you average the time windows, a single file with the average spectrum is produced. |
Shrinking file size by.. Downsampling to Highest Freq. |
Especially useful for the S-Transform, the resulting files might very big and carrying way too much temporal information. F.ex. if the analyzed frequencies were in the range [5..50], you don't really care for time steps smaller than 20 [ms]. This option will optimally downsample the time resolution according to your parameters. Don't use it however if you wish to preserve a per time frame correspondance with your original data, though. |
Process Current |
Enabled when called from an EEG. The analysis applies only to this current file . This button remains disabled until all the parameter dialogs have received enough (and consistent) informations . If this is not the case, first check the current dialog: if its "Next" button is disabled, the problem is in the current dialog. Otherwise, browse the other dialogs for some missing informations. |
Batch Process |
Enabled when not called from an EEG. This will open a dialog for you to pick the set of files (even from different directories) to be analysed. This button remains disabled until all the parameter dialogs have received enough (and consistent) informations . If this is not the case, first check the current dialog: if its "Next" button is disabled, the problem is in the current dialog. Otherwise, browse the other dialogs for some missing informations. You can Drag & Drop files directly to run the Batch Process! |
Cancel |
Quit the dialog. |
Help |
Launch the Help to the right page (should be here...). |
.freq file with all the important informations, if this option has been selected (of course recommended!). Freq files are written in the same directories as their sources. Open them to work with the results.
.sef files for each split electrode, frequency or spectrum, if any of splitting options have been used.
.ApproxEeg.ep file(s), for the approximated EEG of each electrode, for each saved time window (if the "Spectrum" option above has been selected). Note that these files also have the frequencies on the horizontal axis , like the Spectrum.
Verbose file ...<type of analysis>.vrb (text), showing all the parameters.
The FFT Approximation is a very convenient way to retrieve an EEG-like signal, made of signed values, from the FFT results.
To begin with, the FFT, when applied to a time window, always returns results in the Complex space C. Each electrode, for each frequency, is a complex number made of two parts, the real and imaginary values. Hence, we can plot them on a plane (X is the real axis, Y is the imaginary axis), here for one time window, and three successive frequencies:
The FFT Approximation finds the best fitting line in the average referenced data (equivalent to the best fitting dipole), then projects the electrodes complex values on this axis. Being left with a single dimension, a line, we arbitrarily assign a polarity to one direction, and voilà, we have real, signed, scalar values . See again the same three frequencies, for one time window, with the resulting projected electrodes:
We repeat this operation for each time window, see here the first three time windows , for a single frequency (see the rotating pattern due to phase shift of the signal):
You may have noted that the final polarity is arbitrary, which should be accounted for in case of averaging. As long as patterns / topographies are concerns, this is not a real problem, though.
Input files can be anything that looks like tracks:
Be aware that changing the reference of the data
greatly
affects the shape of the signal
, and therefor its frequencies.
This is why the Power Maps and FFT Approximation
presets activate the average reference (as well as some other
parameters), to prevent any accidental change.
By the way, don't use these two methods for intra-cranial electrodes,
this does not make sense at all (again, see article)!
Each window is a part cut from the original file, say from t to t + window_size - 1. Once processed, the results are frequencies for that whole window . Therefor, it is natural to attribute the mean time t + window_size / 2 of that window as its time position in the output file.
Average occurs at the very last stage of the processing. For example, after the Power Maps have been computed. This is not equivalent to the Power Maps of the mean FFT.
When using the Hanning windowing function, the results after analysis are multiplied by a factor 2 to account for the fading introduced by the method.
Smaller time windows gives a higher time resolution, but a lower frequency resolution. Conversely, bigger time windows gives a lower time resolution, and a higher frequency resolution. The dialog, by default, suggest a compromise between the time and frequency resolution, which the user can change.
Here you can see the same time range analysed with a small (64), a medium (256) and a large (1024) time window (for a sampling frequency of 256 Hz):
Frequencies saved and computed usually differ, in the sense that often, more frequencies are available from the transformation than there will be written to file . The most obvious case is when saving a frequency band, all frequencies within that band will be averaged together into a single result. Though, it also applies to the interval case, f.ex. if the saved frequencies are stepping by 1 Hz, and the transformation allows finer steps of 0.5 Hz.
To take benefit from that situation, Cartool will average as much as it can from the available frequencies to produce the requested output results. Let's see how this works.
In the frequency band case:
All frequencies within the specified range (including both limits),
with all the available steps (say, again, 0.5 Hz) will be averaged together.
F.ex.: band 3-8 Hz, with steps of 0.5 Hz, will average frequencies 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5 and 8 Hz.
In the interval case:
You have to specify a range of frequencies, plus a step to save. If
your step is greater than the transformation available step, an
averaging will occur. F.ex. you ask from 3 to 8 Hz, by steps of 1 Hz,
but the resolution allows up to 0.25 Hz, then frequencies 3, 3.25,
3.5 and 3.75 are averaged together for your first saved frequency.
Then 4, 4.25, 4.5 and 4.75 for your second saved frequency etc...
Stated otherwise, they are treated like a serie of small bands.
In any case, you can see in the verbose file what are exactly the frequencies that have been averaged together , if you have any doubt.
FFT Approximation results can also be averaged, as explained here . However some more checkings are to be done.
The problems arise from the fact that the results are signed, real values, as an actual EEG would look like. However, during the FFT Approximation process, the polarity of each map has been assigned to an arbitrary value: a map can be either m or -m, we can not know. This is an important issue when averaging together these maps, as to avoid them to cancel each other for this sign reason.
Thus, Cartool, when dealing with averaging FFT Approximation maps, will perform sign inversions of the maps whose correlation with each others are negative . After the sign inversion the regular summation can take place.
When averaging many frequencies together (either this case or this case), the averaging takes place after converting the results from complex to real values, usually by taking the norm, the squared norm of the results, or through the FFT Approximation.