Commit 6ee40509 authored by Bruno Colombet's avatar Bruno Colombet

Modified ICA plugin to be able to run on selections using markers.

parent 7c62816a
......@@ -107,12 +107,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AwFilteringLib", "src\Filte
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FileConverter", "src\plugins\FileConverter\FileConverter.vcxproj", "{AFBD2728-57CE-429F-8C40-9FB4F8DB905B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ANT_Reader", "src\plugins\ANT_Reader\ANT_Reader.vcxproj", "{F2206D68-3226-41EC-AD37-B314DD27FEFA}"
ProjectSection(ProjectDependencies) = postProject
{CA5B6E48-7EBE-4949-AA0B-79267B704C4D} = {CA5B6E48-7EBE-4949-AA0B-79267B704C4D}
{71DBCBBD-3E14-446C-9275-576E2934BC5B} = {71DBCBBD-3E14-446C-9275-576E2934BC5B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AutoMarking", "src\plugins\AutoMarking\AutoMarking.vcxproj", "{9A321685-9E0B-44CB-88E0-B64DA3418DD9}"
ProjectSection(ProjectDependencies) = postProject
{71DBCBBD-3E14-446C-9275-576E2934BC5B} = {71DBCBBD-3E14-446C-9275-576E2934BC5B}
......@@ -378,14 +372,6 @@ Global
{AFBD2728-57CE-429F-8C40-9FB4F8DB905B}.Release|Win32.Build.0 = Release|Win32
{AFBD2728-57CE-429F-8C40-9FB4F8DB905B}.Release|x64.ActiveCfg = Release|x64
{AFBD2728-57CE-429F-8C40-9FB4F8DB905B}.Release|x64.Build.0 = Release|x64
{F2206D68-3226-41EC-AD37-B314DD27FEFA}.Debug|Win32.ActiveCfg = Debug|Win32
{F2206D68-3226-41EC-AD37-B314DD27FEFA}.Debug|Win32.Build.0 = Debug|Win32
{F2206D68-3226-41EC-AD37-B314DD27FEFA}.Debug|x64.ActiveCfg = Debug|x64
{F2206D68-3226-41EC-AD37-B314DD27FEFA}.Debug|x64.Build.0 = Debug|x64
{F2206D68-3226-41EC-AD37-B314DD27FEFA}.Release|Win32.ActiveCfg = Release|Win32
{F2206D68-3226-41EC-AD37-B314DD27FEFA}.Release|Win32.Build.0 = Release|Win32
{F2206D68-3226-41EC-AD37-B314DD27FEFA}.Release|x64.ActiveCfg = Release|x64
{F2206D68-3226-41EC-AD37-B314DD27FEFA}.Release|x64.Build.0 = Release|x64
{9A321685-9E0B-44CB-88E0-B64DA3418DD9}.Debug|Win32.ActiveCfg = Debug|Win32
{9A321685-9E0B-44CB-88E0-B64DA3418DD9}.Debug|Win32.Build.0 = Debug|Win32
{9A321685-9E0B-44CB-88E0-B64DA3418DD9}.Debug|x64.ActiveCfg = Debug|x64
......@@ -637,7 +623,7 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {760C4A58-27A9-4401-83F8-D863D6C42B7E}
Qt5Version = 5.10
SolutionGuid = {760C4A58-27A9-4401-83F8-D863D6C42B7E}
EndGlobalSection
EndGlobal
......@@ -23,8 +23,10 @@ ICASettings::ICASettings(const QString& dataPath, const AwChannelList& channels,
m_ui.comboIgnoredMarkers->setEnabled(false);
m_ui.checkIgnoreMarker->setEnabled(false);
}
else
else {
m_ui.comboIgnoredMarkers->addItems(m_labels);
m_ui.comboUseMarkers->addItems(m_labels);
}
connect(m_ui.cbAll, SIGNAL(toggled(bool)), this, SLOT(updateMaxNumOfIC()));
connect(m_ui.comboModality, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMaxNumOfIC()));
connect(m_ui.ignoreBads, SIGNAL(toggled(bool)), this, SLOT(updateMaxNumOfIC()));
......@@ -43,8 +45,12 @@ void ICASettings::accept()
{
ignoreBadChannels = m_ui.ignoreBads->isChecked();
ignoreMarkers = m_ui.checkIgnoreMarker->isChecked();
if (!m_labels.isEmpty())
selectedMarker = m_labels.at(m_ui.comboIgnoredMarkers->currentIndex());
useMarkers = m_ui.checkUseMarkers->isChecked();
if (!m_labels.isEmpty()) {
skipMarker = m_labels.at(m_ui.comboIgnoredMarkers->currentIndex());
useMarker = m_labels.at(m_ui.comboUseMarkers->currentIndex());
}
modality = AwChannel::stringToType(m_modes.at(m_ui.comboModality->currentIndex()));
lpf = m_ui.spinLPF->value();
hpf = m_ui.spinHPF->value();
......
......@@ -40,8 +40,8 @@ public:
~ICASettings();
bool ignoreBadChannels;
bool ignoreMarkers;
QString selectedMarker;
bool ignoreMarkers, useMarkers;
QString skipMarker, useMarker;
int modality;
float hpf, lpf;
int components;
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>546</width>
<height>553</height>
<height>424</height>
</rect>
</property>
<property name="windowTitle">
......@@ -23,7 +23,7 @@
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
......@@ -218,22 +218,9 @@
<property name="title">
<string>Data Input</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0">
<widget class="QCheckBox" name="checkIgnoreMarker">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Ignore selection markers labeled</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboModality">
<property name="sizePolicy">
......@@ -267,7 +254,20 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="1" column="0">
<widget class="QCheckBox" name="checkIgnoreMarker">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Ignore markers labeled:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="ignoreBads">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
......@@ -296,6 +296,29 @@
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkUseMarkers">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Only use markers labeled:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboUseMarkers">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
......
......@@ -33,6 +33,7 @@
#include <math/AwMath.h>
#include <filter/AwFilterSettings.h>
#include <QMessageBox>
#include <AwCore.h>
// use layout manager to store a layout in the matlab file
#include <layout/AwLayoutManager.h>
......@@ -69,17 +70,25 @@ bool ICA::showUi()
args["modality"] = AwChannel::typeToString(ui.modality);
if (ui.ignoreMarkers) {
QStringList skippedMarkers = { ui.selectedMarker };
QStringList skippedMarkers = { ui.skipMarker };
args["skip_markers"] = skippedMarkers;
AwMarkerList tmp = AwMarker::getMarkersWithLabels(pdi.input.markers(), skippedMarkers);
auto markers = AwMarker::invertMarkerSelection(tmp, "selection", pdi.input.fileDuration);
pdi.input.setNewMarkers(markers);
//AwMarkerList tmp = AwMarker::getMarkersWithLabels(pdi.input.markers(), skippedMarkers);
//auto markers = AwMarker::invertMarkerSelection(tmp, "selection", pdi.input.fileDuration);
//pdi.input.setNewMarkers(markers);
}
else { // set whole file as input
pdi.input.clearMarkers();
pdi.input.addMarker(new AwMarker("global", 0., pdi.input.fileDuration));
if (ui.useMarkers) {
QStringList markers = { ui.useMarker };
args["skip_markers"] = markers;
}
// use and skip marker labels must be different
if (!ui.useMarker.isEmpty() && !ui.skipMarker.isEmpty())
if (ui.useMarker == ui.skipMarker) {
QMessageBox::critical(0, "Data Input", QString("markers to use and skip must be different."));
return false;
}
// NOT SKIPPING BAD CHANNELS, ok clear badLabels from input.
if (!ui.ignoreBadChannels) {
pdi.input.badLabels.clear();
......@@ -169,14 +178,33 @@ int ICA::initParameters()
// check if we have to use specific markers or skipped some
bool use = args.contains("use_markers");
bool skip = args.contains("skip_markers");
// in the case of one option is set, the AwRunProcess method has already setup the input markers for us if we runFromCommandLine
// If we run in GUI mode, the showUi also has already setup the input.
// But if we run in command line mode and no use_markers or skip_markers is specified we must set the input markers to what ICA expects
if (!use && !skip) {
if (use || skip) {
auto markers = AwMarker::duplicate(pdi.input.markers());
QStringList skippedMarkers, usedMarkers;
if (use)
usedMarkers = args["use_markers"].toStringList();
if (skip)
skippedMarkers = args["skip_markers"].toStringList();
auto inputMarkers = AwMarker::getInputMarkers(markers, skippedMarkers, usedMarkers, pdi.input.fileDuration);
if (inputMarkers.isEmpty()) {
pdi.input.clearMarkers();
pdi.input.addMarker(new AwMarker("whole data", 0., pdi.input.fileDuration));
}
else
{
pdi.input.clearMarkers();
pdi.input.setNewMarkers(inputMarkers);
}
AW_DESTROY_LIST(markers);
}
else { // no markers to use or skip => compute on the whole data
pdi.input.clearMarkers();
pdi.input.addMarker(new AwMarker("global", 0., pdi.input.fileDuration));
pdi.input.addMarker(new AwMarker("whole data", 0., pdi.input.fileDuration));
}
// Watch for memory exception
try {
......@@ -334,5 +362,5 @@ void ICA::saveToFile()
sendMessage(QString("Error saving to .mat : %1").arg(e.errorString()));
return;
}
sendMessage(QString("saved results to %1.").arg(m_fileName));
sendMessage(QString("results saved to %1.").arg(m_fileName));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment