-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
self referencing with reference input
- Loading branch information
Showing
3 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
orangecontrib/snom/widgets/preprocessors/self_reference.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from AnyQt.QtWidgets import QFormLayout, QLabel | ||
|
||
from orangecontrib.spectroscopy.widgets.preprocessors.utils import BaseEditorOrange, REFERENCE_DATA_PARAM | ||
from orangecontrib.spectroscopy.widgets.gui import lineEditIntRange | ||
|
||
from pySNOM.images import SelfReference | ||
|
||
from orangecontrib.snom.preprocess.utils import ( | ||
PreprocessImageOpts2DOnlyWhole, | ||
) | ||
from orangecontrib.snom.widgets.preprocessors.registry import preprocess_image_editors | ||
import numpy as np | ||
|
||
class SelfRef(PreprocessImageOpts2DOnlyWhole): | ||
def __init__(self, reference): | ||
self.reference = reference.X | ||
|
||
def transform_image(self, image): | ||
ref = (np.reshape(self.reference,np.shape(image))) | ||
d = SelfReference(referencedata=ref).transform( | ||
image | ||
) | ||
return d | ||
|
||
|
||
class SelfRefEditor(BaseEditorOrange): | ||
name = "Self-referencing" | ||
qualname = "orangecontrib.snom.self_reference" | ||
|
||
def __init__(self, parent=None, **kwargs): | ||
super().__init__(parent, **kwargs) | ||
|
||
self.reference = None | ||
|
||
form = QFormLayout() | ||
self.reference_info = QLabel("Reference data from input!") | ||
form.addRow(self.reference_info) | ||
self.controlArea.setLayout(form) | ||
|
||
def activateOptions(self): | ||
pass # actions when user starts changing options | ||
|
||
def setParameters(self, params): | ||
self.update_reference_info() | ||
|
||
def set_reference_data(self, reference): | ||
self.reference = reference | ||
self.update_reference_info() | ||
|
||
def update_reference_info(self): | ||
if not self.reference: | ||
self.reference_info.setText("Reference: missing!") | ||
self.reference_info.setStyleSheet("color: red") | ||
else: | ||
rinfo = "Reference order: N" | ||
self.reference_info.setText(rinfo) | ||
self.reference_info.setStyleSheet("color: black") | ||
|
||
@classmethod | ||
def createinstance(cls, params): | ||
params = dict(params) | ||
reference = params.get(REFERENCE_DATA_PARAM, None) | ||
return SelfRef(reference=reference) | ||
|
||
def set_preview_data(self, data): | ||
if data: | ||
pass # TODO any settings | ||
|
||
|
||
preprocess_image_editors.register(SelfRefEditor, 400) |