Skip to content

Commit 22723dc

Browse files
committed
Add support for background images in ANDOR SIF files
Fix #178
1 parent e39e2d9 commit 22723dc

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ See DataLab [roadmap page](https://datalab-platform.com/en/contributing/roadmap.
66

77
💥 New features and enhancements:
88

9+
* ANDOR SIF Images:
10+
* Added support for background images in ANDOR SIF files
11+
* This closes [Issue #178](https://github.com/DataLab-Platform/DataLab/issues/178) - Add support for ANDOR SIF files with background image
912
* Array editor (results, signal and image data, ...):
1013
* New "Copy all" button in the array editor dialog box, to copy all the data in the clipboard, including row and column headers
1114
* New "Export" button in the array editor dialog box, to export the data in a CSV file, including row and column headers

cdl/core/io/image/funcs.py

+24
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,30 @@ def read_all(self) -> np.ndarray:
226226
sif_file.seek(self.m_offset)
227227
block = sif_file.read(self.width * self.height * self.stacksize * 4)
228228
data = np.frombuffer(block, dtype=np.float32)
229+
# If there is a background image, it will be stored just after the signal
230+
# data. The background image is the same size as the signal data.
231+
# To read the background image, we need to search for the next line starting
232+
# with "Counts" and read the data from there.
233+
while True:
234+
line = sif_file.readline()
235+
if not line:
236+
break
237+
if line.startswith(b"Counts"):
238+
# Data starts 4 lines after the "Counts" line
239+
for _ in range(4):
240+
line = sif_file.readline()
241+
# Read the background image data
242+
background_data = sif_file.read(self.width * self.height * 4)
243+
background = np.frombuffer(background_data, dtype=np.float32)
244+
# Check if the background data is the same size as the signal data
245+
if background.size != data.size:
246+
# This is not a background image: not supported format
247+
break
248+
# Add the background data to the signal data, as an additional frame
249+
data = np.concatenate((data, background))
250+
# Update the stack size to include the background image
251+
self.stacksize += 1
252+
break
229253
return data.reshape(self.stacksize, self.height, self.width)
230254

231255

doc/locale/fr/LC_MESSAGES/contributing/changelog.po

+12-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: DataLab \n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2025-04-26 11:17+0200\n"
10+
"POT-Creation-Date: 2025-04-26 15:46+0200\n"
1111
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language: fr\n"
@@ -30,6 +30,15 @@ msgstr "DataLab Version 0.20.0"
3030
msgid "💥 New features and enhancements:"
3131
msgstr "💥 Nouvelles fonctionnalités et améliorations :"
3232

33+
msgid "ANDOR SIF Images:"
34+
msgstr "Images ANDOR SIF :"
35+
36+
msgid "Added support for background images in ANDOR SIF files"
37+
msgstr "Ajout de la prise en charge des images de fond dans les fichiers ANDOR SIF"
38+
39+
msgid "This closes [Issue #178](https://github.com/DataLab-Platform/DataLab/issues/178) - Add support for ANDOR SIF files with background image"
40+
msgstr "Ceci clotûre le ticket [Issue #178](https://github.com/DataLab-Platform/DataLab/issues/178) - Ajout de la prise en charge des fichiers ANDOR SIF avec image de fond"
41+
3342
msgid "Array editor (results, signal and image data, ...):"
3443
msgstr "Éditeur de tableau (résultats, données de signal et d'image, ...)"
3544

@@ -45,7 +54,8 @@ msgstr "Nouvelle fonctionnalité \"Coller\" dans la boîte de dialogue de l'édi
4554
msgid "The features above require guidata v3.9.0 or later"
4655
msgstr "Les fonctionnalités ci-dessus nécessitent guidata v3.9.0 ou une version ultérieure"
4756

48-
msgid "This closes [Issue #174](https://github.com/DataLab-Platform/DataLab/issues/174), [Issue #175](https://github.com/DataLab-Platform/DataLab/issues/175) et [Issue #176](https://github.com/DataLab-Platform/DataLab/issues/176)"
57+
#, fuzzy
58+
msgid "This closes [Issue #174](https://github.com/DataLab-Platform/DataLab/issues/174), [Issue #175](https://github.com/DataLab-Platform/DataLab/issues/175) and [Issue #176](https://github.com/DataLab-Platform/DataLab/issues/176)"
4959
msgstr "Ceci clotûre les tickets [Issue #174](https://github.com/DataLab-Platform/DataLab/issues/174), [Issue #175](https://github.com/DataLab-Platform/DataLab/issues/175) et [Issue #176](https://github.com/DataLab-Platform/DataLab/issues/176)"
5060

5161
msgid "Fourier analysis features (\"Processing\" menu):"

0 commit comments

Comments
 (0)