From c119d753f2a6935e3e3c769160c44a67ae6cb54e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Besson?= <sbesson@glencoesoftware.com>
Date: Tue, 23 Jul 2024 14:31:21 +0100
Subject: [PATCH] PerkinElmerReader: always return the HTM first in the used
 files list

---
 .../formats-gpl/src/loci/formats/in/PerkinElmerReader.java   | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/components/formats-gpl/src/loci/formats/in/PerkinElmerReader.java b/components/formats-gpl/src/loci/formats/in/PerkinElmerReader.java
index 35f2960bfd8..f1dcef32e1a 100644
--- a/components/formats-gpl/src/loci/formats/in/PerkinElmerReader.java
+++ b/components/formats-gpl/src/loci/formats/in/PerkinElmerReader.java
@@ -420,6 +420,9 @@ protected void initFile(String id) throws FormatException, IOException {
 
     LOGGER.info("Finding image files");
 
+    addUsedFile(workingDirPath, htmFile);
+    if (htmFile != null) htmFile = allFiles.get(allFiles.size() - 1);
+
     List<Integer> foundExts = new ArrayList<Integer>();
     for (PixelsFile f : files) {
       if (!foundExts.contains(f.extIndex)) {
@@ -457,8 +460,6 @@ protected void initFile(String id) throws FormatException, IOException {
     if (csvFile != null) csvFile = allFiles.get(allFiles.size() - 1);
     addUsedFile(workingDirPath, zpoFile);
     if (zpoFile != null) zpoFile = allFiles.get(allFiles.size() - 1);
-    addUsedFile(workingDirPath, htmFile);
-    if (htmFile != null) htmFile = allFiles.get(allFiles.size() - 1);
 
     if (timFile != null) parseTimFile(timFile);
     if (csvFile != null) parseCSVFile(csvFile);