more snirf metadata
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
- Removed the option for PPF under Haemoglobin Concentration as it is no longer used.
|
- Removed the option for PPF under Haemoglobin Concentration as it is no longer used.
|
||||||
- Added a new category in the options called Other
|
- Added a new category in the options called Other
|
||||||
- Added MAX_WORKERS to the Other category. This is how many files should be processed at once. Fixes [Issue 13](https://git.research.dezeeuw.ca/tyler/flares/issues/13).
|
- Added MAX_WORKERS to the Other category. This is how many files should be processed at once. Fixes [Issue 13](https://git.research.dezeeuw.ca/tyler/flares/issues/13).
|
||||||
|
- Added more information about the snirf file to be displayed when selected
|
||||||
|
|
||||||
|
|
||||||
# Version 1.0.0
|
# Version 1.0.0
|
||||||
|
|||||||
57
main.py
57
main.py
@@ -1162,7 +1162,7 @@ class MainApplication(QMainWindow):
|
|||||||
created = time.ctime(os.path.getctime(file_path))
|
created = time.ctime(os.path.getctime(file_path))
|
||||||
modified = time.ctime(os.path.getmtime(file_path))
|
modified = time.ctime(os.path.getmtime(file_path))
|
||||||
|
|
||||||
# snirf_info = self.get_snirf_metadata_mne(file_path)
|
snirf_info = self.get_snirf_metadata_mne(file_path)
|
||||||
|
|
||||||
info = f"""\
|
info = f"""\
|
||||||
File: {os.path.basename(file_path)}
|
File: {os.path.basename(file_path)}
|
||||||
@@ -1172,17 +1172,17 @@ class MainApplication(QMainWindow):
|
|||||||
Full Path: {file_path}
|
Full Path: {file_path}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# if "Error" in snirf_info:
|
if "Error" in snirf_info:
|
||||||
# info += f"\nSNIRF Metadata could not be loaded: {snirf_info['Error']}"
|
info += f"\nSNIRF Metadata could not be loaded: {snirf_info['Error']}"
|
||||||
# else:
|
else:
|
||||||
# info += "\nSNIRF Metadata:\n"
|
info += "\nSNIRF Metadata:\n"
|
||||||
# for k, v in snirf_info.items():
|
for k, v in snirf_info.items():
|
||||||
# if isinstance(v, list):
|
if isinstance(v, list):
|
||||||
# info += f" {k}:\n"
|
info += f" {k}:\n"
|
||||||
# for item in v:
|
for item in v:
|
||||||
# info += f" - {item}\n"
|
info += f" - {item}\n"
|
||||||
# else:
|
else:
|
||||||
# info += f" {k}: {v}\n"
|
info += f" {k}: {v}\n"
|
||||||
|
|
||||||
self.top_left_widget.setText(info)
|
self.top_left_widget.setText(info)
|
||||||
|
|
||||||
@@ -1543,6 +1543,39 @@ class MainApplication(QMainWindow):
|
|||||||
def normalize(v): return [int(x) for x in v.split(".")]
|
def normalize(v): return [int(x) for x in v.split(".")]
|
||||||
return (normalize(v1) > normalize(v2)) - (normalize(v1) < normalize(v2))
|
return (normalize(v1) > normalize(v2)) - (normalize(v1) < normalize(v2))
|
||||||
|
|
||||||
|
def get_snirf_metadata_mne(self, file_name):
|
||||||
|
import mne
|
||||||
|
from mne.preprocessing.nirs import source_detector_distances
|
||||||
|
|
||||||
|
raw = mne.io.read_raw_snirf(file_name, preload=True)
|
||||||
|
|
||||||
|
snirf_info = {}
|
||||||
|
|
||||||
|
# Measurement date
|
||||||
|
snirf_info['Measurement Date'] = str(raw.info.get('meas_date'))
|
||||||
|
|
||||||
|
# Source-detector distances
|
||||||
|
distances = source_detector_distances(raw.info)
|
||||||
|
distance_info = []
|
||||||
|
for ch_name, dist in zip(raw.info['ch_names'], distances):
|
||||||
|
distance_info.append(f"{ch_name}: {dist:.4f} m")
|
||||||
|
snirf_info['Source-Detector Distances'] = distance_info
|
||||||
|
|
||||||
|
# Digitization points / optode positions
|
||||||
|
dig = raw.info.get('dig', None)
|
||||||
|
if dig is not None:
|
||||||
|
dig_info = []
|
||||||
|
for point in dig:
|
||||||
|
kind = point['kind']
|
||||||
|
ident = point['ident']
|
||||||
|
coord = point['r']
|
||||||
|
dig_info.append(f"Kind: {kind}, ID: {ident}, Coord: {coord}")
|
||||||
|
snirf_info['Digitization Points'] = dig_info
|
||||||
|
else:
|
||||||
|
snirf_info['Digitization Points'] = "Not found"
|
||||||
|
|
||||||
|
return snirf_info
|
||||||
|
|
||||||
|
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
# Gracefully shut down multiprocessing children
|
# Gracefully shut down multiprocessing children
|
||||||
|
|||||||
Reference in New Issue
Block a user