MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / run

Method run

ij/src/main/java/ij/plugin/FITS_Reader.java:130–318  ·  view source on GitHub ↗

Main processing method for the FITS_Reader object @param path path of FITS file

(String path)

Source from the content-addressed store, hash-verified

128 * @param path path of FITS file
129 */
130 public void run(String path) {
131 // wcs = null;
132 imagePlus = null;
133
134 AIJLogger.setLogAutoCloses(Prefs.getBoolean(AIJLogger.CERTAIN_LOGS_AUTO_CLOSE, true));
135
136 if (USE_NEW_READER) {
137 try (var r = FitsReader.create(path)) {
138 if (r.size() <= 0) {
139 if (r.isMeasurementsTable()) {
140 // Read table
141 r.getHeaders();
142 }
143
144 return;
145 }
146
147 setFileInfo(r.decodeFileInfo());
148 var hdrs = r.getHeaders();
149 setProperty("Info", hdrs[0]);
150
151 fileName = r.fileName;
152 fileType = r.fileType;
153 fileBase = r.fileBase;
154
155 if (HEADER_ONLY.orElse(false)) {
156 // Needed for slice info to update
157 setProcessor(fileName, REF_SLICE.orElse(new ByteProcessor(width, height)));
158
159 IJ.showStatus("");
160 return;
161 }
162
163 var ips = r.getProcessors();
164
165 if (r.size() == 1) {
166 setProcessor(fileName, ips[0]);
167 if (imagePlus == null) return;
168 var imageProcessor = imagePlus.getProcessor();
169 imageProcessor.flipVertical();
170 setProcessor(fileName, imageProcessor);
171 } else if (r.size() > 1) {
172 var stack = new ImageStack();
173 for (int i = 0; i < r.size(); i++) {
174 stack.addSlice(fileBase + "_" +
175 (r.size() < 10000 ? fourDigits.format(i + 1) : (i + 1)) +
176 (!fileType.isEmpty() ? "." + fileType : "") + "\n" + hdrs[i], ips[i]);
177 }
178
179 setStack(fileName, stack);
180 }
181 IJ.showStatus("");
182 } catch (Exception e) {
183 throw new RuntimeException("Error reading Fits file at " + path, e);
184 }
185
186 return;
187 }

Callers 2

readStackMethod · 0.95
readImageMethod · 0.95

Calls 15

setLogAutoClosesMethod · 0.95
getBooleanMethod · 0.95
createMethod · 0.95
decodeFileInfoMethod · 0.95
showStatusMethod · 0.95
addSliceMethod · 0.95
getHDUMethod · 0.95
firstImageHDUMethod · 0.95
errorMethod · 0.95
closeMethod · 0.95
isCompressedFormatMethod · 0.95

Tested by 2

readStackMethod · 0.76
readImageMethod · 0.76