|
25 | 25 | import java.io.File; |
26 | 26 | import java.net.URI; |
27 | 27 | import java.util.ArrayList; |
28 | | -import java.util.Arrays; |
29 | 28 | import java.util.HashMap; |
30 | 29 | import java.util.HashSet; |
31 | 30 | import java.util.List; |
|
39 | 38 | import org.janelia.saalfeldlab.n5.imglib2.N5Utils; |
40 | 39 | import org.janelia.saalfeldlab.n5.universe.StorageFormat; |
41 | 40 |
|
42 | | -import ij.ImageJ; |
43 | | -import mpicbg.spim.data.SpimDataException; |
44 | | -import mpicbg.spim.data.registration.ViewRegistration; |
45 | | -import mpicbg.spim.data.sequence.MultiResolutionSetupImgLoader; |
46 | | -import mpicbg.spim.data.sequence.SequenceDescription; |
47 | | -import mpicbg.spim.data.sequence.SetupImgLoader; |
48 | | -import mpicbg.spim.data.sequence.ViewDescription; |
49 | 41 | import mpicbg.spim.data.sequence.ViewId; |
50 | 42 | import net.imglib2.RandomAccess; |
51 | 43 | import net.imglib2.RandomAccessibleInterval; |
52 | | -import net.imglib2.img.display.imagej.ImageJFunctions; |
53 | | -import net.imglib2.multithreading.SimpleMultiThreading; |
54 | 44 | import net.imglib2.position.FunctionRandomAccessible; |
55 | | -import net.imglib2.realtransform.AffineTransform3D; |
56 | 45 | import net.imglib2.type.numeric.integer.UnsignedLongType; |
57 | 46 | import net.imglib2.type.numeric.real.DoubleType; |
58 | 47 | import net.imglib2.util.Pair; |
59 | 48 | import net.imglib2.util.ValuePair; |
60 | 49 | import net.imglib2.view.Views; |
61 | 50 | import net.preibisch.legacy.io.IOFunctions; |
62 | | -import net.preibisch.mvrecon.fiji.spimdata.SpimData2; |
63 | | -import net.preibisch.mvrecon.fiji.spimdata.XmlIoSpimData2; |
64 | | -import net.preibisch.mvrecon.process.interestpointregistration.pairwise.constellation.grouping.Group; |
65 | 51 | import util.URITools; |
66 | 52 |
|
67 | 53 | public class InterestPointsN5 extends InterestPoints |
68 | 54 | { |
69 | | - public static void main( String[] args ) throws SpimDataException |
70 | | - { |
71 | | - int viewSetupId = 1; |
72 | | - |
73 | | - // |
74 | | - // works without the XML, just loads the N5 directly |
75 | | - // |
76 | | - InterestPointsN5 ip = new InterestPointsN5( |
77 | | - URI.create("/nrs/saalfeld/john/for/keller/danio_1_488/dataset-orig-tifs/3/"), |
78 | | - "tpId_0_viewSetupId_" + viewSetupId + "/beads8v2" ); |
79 | | - |
80 | | - List<InterestPoint> points = ip.getInterestPointsCopy(); |
81 | | - |
82 | | - for ( final InterestPoint p : points ) |
83 | | - { |
84 | | - //System.out.println( p.getId() + " " + Arrays.toString( p.getL() )); |
85 | | - } |
86 | | - |
87 | | - // |
88 | | - // this needs the XML |
89 | | - // |
90 | | - SpimData2 data = new XmlIoSpimData2().load( URI.create("file:/nrs/saalfeld/john/for/keller/danio_1_488/dataset-orig-tifs/3/dataset-stephan.xml") ); |
91 | | - |
92 | | - ViewId myViewId = new ViewId( 0, viewSetupId ); |
93 | | - |
94 | | - // calibration etc |
95 | | - SequenceDescription sd = data.getSequenceDescription(); |
96 | | - ViewDescription vd = sd.getViewDescription( myViewId ); |
97 | | - System.out.println( "voxelSize: " + Arrays.toString( vd.getViewSetup().getVoxelSize().dimensionsAsDoubleArray() ) ); |
98 | | - System.out.println( "tile id: " + vd.getViewSetup().getTile().getId() ); |
99 | | - |
100 | | - SetupImgLoader<?> setupImgLoader = sd.getImgLoader().getSetupImgLoader( myViewId.getViewSetupId() ); |
101 | | - |
102 | | - // full res |
103 | | - RandomAccessibleInterval<?> img = setupImgLoader.getImage( myViewId.getTimePointId() ); |
104 | | - |
105 | | - // multi-res |
106 | | - if ( MultiResolutionSetupImgLoader.class.isInstance( setupImgLoader ) ) |
107 | | - { |
108 | | - RandomAccessibleInterval imgS3 = ((MultiResolutionSetupImgLoader)setupImgLoader).getImage( myViewId.getTimePointId(), 3 ); |
109 | | - double[][] mipMapSteps = ((MultiResolutionSetupImgLoader)setupImgLoader).getMipmapResolutions(); |
110 | | - AffineTransform3D[] mipMapT = ((MultiResolutionSetupImgLoader)setupImgLoader).getMipmapTransforms(); |
111 | | - new ImageJ(); |
112 | | - ImageJFunctions.show( imgS3 ); |
113 | | - } |
114 | | - |
115 | | - // dealing with transforms |
116 | | - Map<ViewId, ViewRegistration> rMap = data.getViewRegistrations().getViewRegistrations(); |
117 | | - ViewRegistration reg = rMap.get( myViewId ); |
118 | | - System.out.println( "num transformations: " + reg.getTransformList().size() ); |
119 | | - reg.updateModel(); |
120 | | - System.out.println( "concatenated model: " + reg.getModel() ); |
121 | | - |
122 | | - // dealing with interest points |
123 | | - Map<ViewId, ViewInterestPointLists> iMap = data.getViewInterestPoints().getViewInterestPoints(); |
124 | | - ViewInterestPointLists iplists = iMap.get( myViewId ); |
125 | | - |
126 | | - System.out.println( "\navailable interest point labels:"); |
127 | | - iplists.getHashMap().keySet().forEach( k -> System.out.println( k ) ); |
128 | | - String myLabel = "beads8v2"; |
129 | | - InterestPoints ips = iplists.getInterestPointList( myLabel ); // this is net.preibisch.mvrecon.fiji.spimdata.interestpoints.InterestPointsN5 |
130 | | - |
131 | | - // load interest points |
132 | | - List<InterestPoint> p = ips.getInterestPointsCopy(); |
133 | | - |
134 | | - for ( int j = 0; j < 15; ++j ) |
135 | | - { |
136 | | - InterestPoint point = p.get( j ); |
137 | | - System.out.println( point.getId() + ": " + Arrays.toString( point.getL() ) ); |
138 | | - } |
139 | | - |
140 | | - // load correspondences |
141 | | - List<CorrespondingInterestPoints> cp = ips.getCorrespondingInterestPointsCopy(); |
142 | | - |
143 | | - AffineTransform3D myModel = rMap.get( myViewId ).getModel(); |
144 | | - |
145 | | - System.out.println( "\nCorrespondences" ); |
146 | | - for ( int k = 0; k < cp.size(); ++k ) |
147 | | - { |
148 | | - CorrespondingInterestPoints cpoint = cp.get( k ); |
149 | | - |
150 | | - int myId = cpoint.getDetectionId(); |
151 | | - String otherLabel = cpoint.getCorrespodingLabel(); |
152 | | - ViewId otherViewId = cpoint.getCorrespondingViewId(); |
153 | | - int otherId = cpoint.getCorrespondingDetectionId(); |
154 | | - |
155 | | - InterestPoint myPoint = p.get( myId ); |
156 | | - |
157 | | - InterestPoints pOther = iMap.get( otherViewId ).getInterestPointList( otherLabel ); |
158 | | - InterestPoint otherPoint = pOther.getInterestPointsCopy().get( otherId ); |
159 | | - AffineTransform3D otherModel = rMap.get( otherViewId ).getModel(); |
160 | | - |
161 | | - myModel.apply( myPoint.getL(), myPoint.getW() ); |
162 | | - otherModel.apply( otherPoint.getL(), otherPoint.getW() ); |
163 | | - |
164 | | - System.out.println( |
165 | | - Group.pvid( myViewId ) + " label=" + myLabel +" id=" + myId + ", l=" + Arrays.toString( myPoint.getL() ) + " corresponds to " + |
166 | | - Group.pvid( otherViewId ) + " label=" + otherLabel +" id=" + otherId + ", l=" + Arrays.toString( otherPoint.getL() ) ); |
167 | | - |
168 | | - System.out.println( "w=" + Arrays.toString( myPoint.getW() ) + " >>> w=" + Arrays.toString( otherPoint.getW() ) ); |
169 | | - } |
170 | | - |
171 | | - // load and modify all interest points |
172 | | - iMap.values().forEach( list -> |
173 | | - { |
174 | | - list.getHashMap().keySet().forEach( label -> { |
175 | | - list.getInterestPointList( label ).getInterestPointsCopy(); |
176 | | - list.getInterestPointList( label ).getCorrespondingInterestPointsCopy(); |
177 | | - list.getInterestPointList( label ).setBaseDir( URI.create("file:/nrs/saalfeld/john/for/keller/danio_1_488/dataset-orig-tifs/3/test/")); |
178 | | - }); |
179 | | - }); |
180 | | - |
181 | | - new XmlIoSpimData2().save( data, URI.create("file:/nrs/saalfeld/john/for/keller/danio_1_488/dataset-orig-tifs/3/test/dataset-stephan-2.xml") ); |
182 | | - } |
183 | | - |
184 | 55 | public static int defaultBlockSize = 300_000; |
185 | 56 | public static final String baseN5 = "interestpoints.n5"; |
186 | 57 |
|
|
0 commit comments