Skip to content

Commit a1c16b1

Browse files
committed
Miscellaneous fixes
Added a Long Type to fix errors in the metadata reader caused by reading integers greater than 2^31 Enclosed in try/catch all decoding of numbers from the yaml files Added support for sldyz and npyz files, which store the data compressed, using the zstd codecs Added support of 2D timelapse dats stored in a single file (SFMT -> Single File Multi Timpoint) Fixed GetVoxelSize to accont for magnification Fixed bugs in the usage of the string substring method Fixed allocation of byte buffer to read a plane. Allocation was twice as large as needed. Added code to import ROI's annotations when Metadata level is not Minimum Fixed adding Plane Exposure Time to metadata store Fixed error: "YAMLException: The incoming YAML document exceeds the limit: 3145728 code points." for very large yaml files by using yaml LoaderOptions setCodePointLimit.
1 parent 88a487c commit a1c16b1

File tree

2 files changed

+54
-9
lines changed

2 files changed

+54
-9
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ tools/*.jar
2020
*.iml
2121
.*.swp
2222
*.clean
23-
.vscode
23+
.vscode
24+
components/formats-gpl/src/loci/formats/in/SlideBook6Reader.java

components/formats-bsd/src/loci/formats/in/SlideBook7Reader.java

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import java.util.List;
4949
import static java.lang.Integer.max;
5050

51+
import org.yaml.snakeyaml.LoaderOptions;
5152
import org.yaml.snakeyaml.nodes.MappingNode;
5253
import org.yaml.snakeyaml.nodes.Node;
5354
import org.yaml.snakeyaml.nodes.NodeTuple;
@@ -1063,7 +1064,13 @@ public Boolean LoadChannelRecord()
10631064
{
10641065
try (InputStream inputStream = new FileInputStream(mFile.GetImageGroupDirectory(mImageTitle) + CSBFile70.kChannelRecordFilename);
10651066
Reader inputStreamReader = new InputStreamReader(inputStream);) {
1066-
Yaml yaml = new Yaml();
1067+
// making sure that the yaml code limit is big enough for this file
1068+
String thePath = mFile.GetImageGroupDirectory(mImageTitle) + CSBFile70.kChannelRecordFilename;
1069+
File fil = new File(thePath);
1070+
long length = fil.length();
1071+
LoaderOptions loadingConfig = new LoaderOptions();
1072+
loadingConfig.setCodePointLimit((int)length + 10000);
1073+
Yaml yaml = new Yaml(loadingConfig);
10671074
MappingNode theNode = (MappingNode)yaml.compose(inputStreamReader);
10681075
int theLastIndex = 0;
10691076
StrIntPair thePair;
@@ -1147,7 +1154,13 @@ public Boolean LoadMaks()
11471154
{
11481155
try (InputStream inputStream = new FileInputStream(mFile.GetImageGroupDirectory(mImageTitle) + CSBFile70.kMaskRecordFilename);
11491156
Reader inputStreamReader = new InputStreamReader(inputStream);) {
1150-
Yaml yaml = new Yaml();
1157+
// making sure that the yaml code limit is big enough for this file
1158+
String thePath = mFile.GetImageGroupDirectory(mImageTitle) + CSBFile70.kMaskRecordFilename;
1159+
File fil = new File(thePath);
1160+
long length = fil.length();
1161+
LoaderOptions loadingConfig = new LoaderOptions();
1162+
loadingConfig.setCodePointLimit((int)length + 10000);
1163+
Yaml yaml = new Yaml(loadingConfig);
11511164
MappingNode theNode = (MappingNode)yaml.compose(inputStreamReader);
11521165
int theLastIndex = 0;
11531166
List<NodeTuple> theValueClassList = theNode.getValue();
@@ -1216,7 +1229,13 @@ public Boolean LoadAnnotations()
12161229
{
12171230
try (InputStream inputStream = new FileInputStream(mFile.GetImageGroupDirectory(mImageTitle) + CSBFile70.kAnnotationRecordFilename);
12181231
Reader inputStreamReader = new InputStreamReader(inputStream);) {
1219-
Yaml yaml = new Yaml();
1232+
// making sure that the yaml code limit is big enough for this file
1233+
String thePath = mFile.GetImageGroupDirectory(mImageTitle) + CSBFile70.kAnnotationRecordFilename;
1234+
File fil = new File(thePath);
1235+
long length = fil.length();
1236+
LoaderOptions loadingConfig = new LoaderOptions();
1237+
loadingConfig.setCodePointLimit((int)length + 10000);
1238+
Yaml yaml = new Yaml(loadingConfig);
12201239
MappingNode theNode = (MappingNode)yaml.compose(inputStreamReader);
12211240
int theLastIndex = 0;
12221241
CDataTableHeaderRecord70 theDataTableHeaderRecord70 = new CDataTableHeaderRecord70();
@@ -1291,7 +1310,13 @@ public Boolean LoadElapsedTimes()
12911310
{
12921311
try (InputStream inputStream = new FileInputStream(mFile.GetImageGroupDirectory(mImageTitle) + CSBFile70.kElapsedTimesFilename);
12931312
Reader inputStreamReader = new InputStreamReader(inputStream);) {
1294-
Yaml yaml = new Yaml();
1313+
// making sure that the yaml code limit is big enough for this file
1314+
String thePath = mFile.GetImageGroupDirectory(mImageTitle) + CSBFile70.kElapsedTimesFilename;
1315+
File fil = new File(thePath);
1316+
long length = fil.length();
1317+
LoaderOptions loadingConfig = new LoaderOptions();
1318+
loadingConfig.setCodePointLimit((int)length + 10000);
1319+
Yaml yaml = new Yaml(loadingConfig);
12951320
MappingNode theNode = (MappingNode)yaml.compose(inputStreamReader);
12961321
ScalarNode theKeyNode;
12971322
Node theCurrentNode;
@@ -1315,7 +1340,13 @@ public Boolean LoadSAPositions()
13151340
{
13161341
try (InputStream inputStream = new FileInputStream(mFile.GetImageGroupDirectory(mImageTitle) + CSBFile70.kSAPositionDataFilename);
13171342
Reader inputStreamReader = new InputStreamReader(inputStream);) {
1318-
Yaml yaml = new Yaml();
1343+
// making sure that the yaml code limit is big enough for this file
1344+
String thePath = mFile.GetImageGroupDirectory(mImageTitle) + CSBFile70.kSAPositionDataFilename;
1345+
File fil = new File(thePath);
1346+
long length = fil.length();
1347+
LoaderOptions loadingConfig = new LoaderOptions();
1348+
loadingConfig.setCodePointLimit((int)length + 10000);
1349+
Yaml yaml = new Yaml(loadingConfig);
13191350
MappingNode theNode = (MappingNode)yaml.compose(inputStreamReader);
13201351
ScalarNode theKeyNode;
13211352
Node theCurrentNode;
@@ -1350,7 +1381,13 @@ public Boolean LoadStagePosition()
13501381
{
13511382
try (InputStream inputStream = new FileInputStream(mFile.GetImageGroupDirectory(mImageTitle) + CSBFile70.kStagePositionDataFilename);
13521383
Reader inputStreamReader = new InputStreamReader(inputStream);) {
1353-
Yaml yaml = new Yaml();
1384+
// making sure that the yaml code limit is big enough for this file
1385+
String thePath = mFile.GetImageGroupDirectory(mImageTitle) + CSBFile70.kStagePositionDataFilename;
1386+
File fil = new File(thePath);
1387+
long length = fil.length();
1388+
LoaderOptions loadingConfig = new LoaderOptions();
1389+
loadingConfig.setCodePointLimit((int)length + 10000);
1390+
Yaml yaml = new Yaml(loadingConfig);
13541391
MappingNode theNode = (MappingNode)yaml.compose(inputStreamReader);
13551392
ScalarNode theKeyNode;
13561393
Node theCurrentNode;
@@ -1388,7 +1425,14 @@ public Boolean LoadAuxData()
13881425
{
13891426
try (InputStream inputStream = new FileInputStream(mFile.GetImageGroupDirectory(mImageTitle) + CSBFile70.kAuxDataFilename);
13901427
Reader inputStreamReader = new InputStreamReader(inputStream);) {
1391-
Yaml yaml = new Yaml();
1428+
// making sure that the yaml code limit is big enough for this file
1429+
String thePath = mFile.GetImageGroupDirectory(mImageTitle) + CSBFile70.kAuxDataFilename;
1430+
File fil = new File(thePath);
1431+
long length = fil.length();
1432+
LoaderOptions loadingConfig = new LoaderOptions();
1433+
loadingConfig.setCodePointLimit((int)length + 10000);
1434+
Yaml yaml = new Yaml(loadingConfig);
1435+
//Yaml yaml = new Yaml();
13921436
MappingNode theNode = (MappingNode)yaml.compose(inputStreamReader);
13931437
ScalarNode theKeyNode;
13941438
Node theCurrentNode;
@@ -3048,7 +3092,7 @@ protected void initFile(String id) throws FormatException, IOException {
30483092

30493093
// set exposure time
30503094
int expTime = theCurrentImageGroup.GetExposureTime(channel);
3051-
store.setPlaneExposureTime(new Time(Double.valueOf(expTime), UNITS.MILLISECOND), capture, imageIndex);
3095+
store.setPlaneExposureTime(new Time(new Double(expTime), UNITS.MILLISECOND), capture, imageIndex);
30523096

30533097
// set tile xy position
30543098
double numberX = theCurrentImageGroup.GetXPosition( position);

0 commit comments

Comments
 (0)