@@ -219,21 +219,21 @@ public GenericBackendDialogN5(
219
219
dataset .set ( "" );
220
220
}
221
221
222
- public void updateDatasetInfo ( final String dataset , final DatasetInfo info )
222
+ public void updateDatasetInfo ( final String group , final DatasetInfo info )
223
223
{
224
224
225
- LOG .debug ( "Updating dataset info for dataset {}" , dataset );
225
+ LOG .debug ( "Updating dataset info for dataset {}" , group );
226
226
try
227
227
{
228
228
final N5Reader n5 = this .n5 .get ();
229
- final String ds = N5Helpers . isMultiScale ( n5 , dataset ) ? N5Helpers . getFinestLevel ( n5 , dataset ) : dataset ;
230
- LOG . debug ( "Got dataset={}, ds={}" , dataset , ds );
231
-
232
- setResolution ( N5Helpers . getResolution ( n5 , dataset ) );
233
- setOffset ( N5Helpers .getOffset ( n5 , dataset ) );
234
- final DatasetAttributes dsAttrs = n5 . getDatasetAttributes ( ds );
235
- this .datasetInfo .minProperty ().set ( Optional .ofNullable ( n5 .getAttribute ( dataset , MIN_KEY , Double .class ) ).orElse ( N5Helpers .minForType ( dsAttrs . getDataType () ) ) );
236
- this .datasetInfo .maxProperty ().set ( Optional .ofNullable ( n5 .getAttribute ( dataset , MAX_KEY , Double .class ) ).orElse ( N5Helpers .maxForType ( dsAttrs . getDataType () ) ) );
229
+
230
+ setResolution ( N5Helpers . getResolution ( n5 , group ) );
231
+ setOffset ( N5Helpers . getOffset ( n5 , group ) );
232
+
233
+ final DataType dataType = N5Helpers .getDataType ( n5 , group );
234
+
235
+ this .datasetInfo .minProperty ().set ( Optional .ofNullable ( n5 .getAttribute ( group , MIN_KEY , Double .class ) ).orElse ( N5Helpers .minForType ( dataType ) ) );
236
+ this .datasetInfo .maxProperty ().set ( Optional .ofNullable ( n5 .getAttribute ( group , MAX_KEY , Double .class ) ).orElse ( N5Helpers .maxForType ( dataType ) ) );
237
237
}
238
238
catch ( final IOException e )
239
239
{
@@ -290,17 +290,19 @@ public IdService idService()
290
290
final String dataset = this .dataset .get ();
291
291
292
292
final Long maxId = n5 .getAttribute ( dataset , "maxId" , Long .class );
293
+ final boolean isPainteraData = N5Helpers .isPainteraDataset ( n5 , dataset );
293
294
final long actualMaxId ;
294
295
if ( maxId == null )
295
296
{
297
+ final String ds = isPainteraData ? dataset + "/" + N5Helpers .PAINTERA_DATA_DATASET : dataset ;
296
298
if ( isLabelMultisetType () )
297
299
{
298
300
LOG .debug ( "Getting id service for label multisets" );
299
- actualMaxId = maxIdLabelMultiset ( n5 , dataset );
301
+ actualMaxId = maxIdLabelMultiset ( n5 , ds );
300
302
}
301
303
else if ( isIntegerType () )
302
304
{
303
- actualMaxId = maxId ( n5 , dataset );
305
+ actualMaxId = maxId ( n5 , ds );
304
306
}
305
307
else
306
308
{
@@ -490,7 +492,12 @@ public boolean isLabelType() throws Exception
490
492
491
493
public boolean isLabelMultisetType () throws Exception
492
494
{
493
- final Boolean attribute = getAttribute ( LABEL_MULTISETTYPE_KEY , Boolean .class );
495
+ final N5Writer n5 = this .n5 .get ();
496
+ final String dataset = this .dataset .get ();
497
+ final Boolean attribute = n5 .getAttribute (
498
+ N5Helpers .isPainteraDataset ( n5 , dataset ) ? dataset + "/" + N5Helpers .PAINTERA_DATA_DATASET : dataset ,
499
+ N5Helpers .LABEL_MULTISETTYPE_KEY ,
500
+ Boolean .class );
494
501
LOG .debug ( "Getting label multiset attribute: {}" , attribute );
495
502
return Optional .ofNullable ( attribute ).orElse ( false );
496
503
}
@@ -535,28 +542,6 @@ public boolean isIntegerType() throws Exception
535
542
return new CommitCanvasN5 ( writer , dataset );
536
543
}
537
544
538
- public < T > T getAttribute ( final String key , final Class < T > clazz ) throws IOException
539
- {
540
- final N5Reader n5 = this .n5 .get ();
541
- final String ds = this .dataset .get ();
542
-
543
- if ( n5 .datasetExists ( ds ) )
544
- {
545
- LOG .debug ( "Getting attributes for {} and {}" , n5 , ds );
546
- return n5 .getAttribute ( ds , key , clazz );
547
- }
548
-
549
- final String [] scaleDirs = N5Helpers .listAndSortScaleDatasets ( n5 , ds );
550
-
551
- if ( scaleDirs .length > 0 )
552
- {
553
- LOG .warn ( "Getting attributes for mipmap dataset: {} and {}" , n5 , scaleDirs [ 0 ] );
554
- return n5 .getAttribute ( Paths .get ( ds , scaleDirs [ 0 ] ).toString (), key , clazz );
555
- }
556
-
557
- throw new RuntimeException ( String .format ( "Cannot read dataset attributes for group %s and dataset %s." , n5 , ds ) );
558
- }
559
-
560
545
public ExecutorService propagationExecutor ()
561
546
{
562
547
return this .propagationExecutor ;
0 commit comments