@@ -130,11 +130,11 @@ bool Maximas::load( nifti_image *pHeader, nifti_image *pBody )
130130 }
131131 if ( pHeader->sto_xyz .m [1 ][1 ] < 0.0 )
132132 {
133- m_originalSagOrientation = ORIENTATION_ANT_TO_POST ;
133+ m_originalSagOrientation = ORIENTATION_POST_TO_ANT ;
134134 }
135135 else
136136 {
137- m_originalSagOrientation = ORIENTATION_POST_TO_ANT ;
137+ m_originalSagOrientation = ORIENTATION_ANT_TO_POST ;
138138 }
139139 }
140140 else if ( pHeader->qform_code > 0 )
@@ -149,11 +149,11 @@ bool Maximas::load( nifti_image *pHeader, nifti_image *pBody )
149149 }
150150 if ( pHeader->qto_xyz .m [1 ][1 ] < 0.0 )
151151 {
152- m_originalSagOrientation = ORIENTATION_ANT_TO_POST ;
152+ m_originalSagOrientation = ORIENTATION_POST_TO_ANT ;
153153 }
154154 else
155155 {
156- m_originalSagOrientation = ORIENTATION_POST_TO_ANT ;
156+ m_originalSagOrientation = ORIENTATION_ANT_TO_POST ;
157157 }
158158 }
159159
@@ -163,7 +163,7 @@ bool Maximas::load( nifti_image *pHeader, nifti_image *pBody )
163163 RTTrackingHelper::getInstance ()->setMaximaFlip (Vector (-1 ,1 ,1 ));
164164 flipAnat ( X_AXIS );
165165 }
166- if ( m_originalSagOrientation == ORIENTATION_ANT_TO_POST )
166+ if ( m_originalSagOrientation == ORIENTATION_POST_TO_ANT )
167167 {
168168 flipAxis ( Y_AXIS, true );
169169 RTTrackingHelper::getInstance ()->setMaximaFlip (Vector (1 ,-1 ,1 ));
@@ -264,32 +264,24 @@ bool Maximas::createStructure ( std::vector< float > &i_fileFloatData )
264264
265265 FMatrix transform = FMatrix ( DatasetManager::getInstance ()->getNiftiTransform () );
266266 FMatrix rotMat ( 3 , 3 );
267- transform.getSubMatrix ( rotMat, 0 , 0 );
268- rotMat (0 ,0 ) = 1 ;
269- rotMat (1 ,1 ) = 1 ;
270- rotMat (2 ,2 ) = 1 ;
271- storedRot = rotMat;
272-
273-
274- /* float voxelX = DatasetManager::getInstance()->getVoxelX();
275- float voxelY = DatasetManager::getInstance()->getVoxelY();
276- float voxelZ = DatasetManager::getInstance()->getVoxelZ();
277- FMatrix transform = FMatrix( DatasetManager::getInstance()->getNiftiTransform() );
278- FMatrix rotMat( 3, 3 );
279- transform.getSubMatrix( rotMat, 0, 0 );
280- rotMat(0,0) = 1;
281- rotMat(1,1) = 1;
282- rotMat(2,2) = 1;
283- FMatrix test( rotMat );
284- test = invert(rotMat);
285- rotMat = test;*/
267+ transform.getSubMatrix ( rotMat, 0 , 0 );
268+
269+ storedRot = rotMat*(1 .0f /abs (rotMat (0 ,0 ))); // Divide by identity values for scaling
286270
271+ // std::cout << storedRot( 0, 0 ) << " " << storedRot( 0, 1 ) << " " << storedRot( 0, 2 ) << std::endl;
272+ // std::cout << storedRot( 1, 0 ) << " " << storedRot( 1, 1 ) << " " << storedRot( 1, 2 ) << std::endl;
273+ // std::cout << storedRot( 2, 0 ) << " " << storedRot( 2, 1 ) << " " << storedRot( 2, 2 ) << std::endl;
274+ //
287275 // Fetching the directions
288276 for ( it = i_fileFloatData.begin (), i = 0 ; it != i_fileFloatData.end (); it += m_bands, ++i )
289277 {
290- m_mainDirections[i].insert ( m_mainDirections[i].end (), it, it + m_bands );
278+ m_mainDirections[i].insert ( m_mainDirections[i].end (), it, it + m_bands );
279+ }
291280
292- /* FMatrix p1( 3, 1 );
281+ for ( int i = 0 ; i < m_mainDirections.size (); i++ )
282+ {
283+
284+ FMatrix p1 ( 3 , 1 );
293285 FMatrix p2 ( 3 , 1 );
294286 FMatrix p3 ( 3 , 1 );
295287 p1 ( 0 , 0 ) = m_mainDirections[i][0 ];
@@ -300,14 +292,13 @@ bool Maximas::createStructure ( std::vector< float > &i_fileFloatData )
300292 p2 ( 1 , 0 ) = m_mainDirections[i][4 ];
301293 p2 ( 2 , 0 ) = m_mainDirections[i][5 ];
302294
303-
304295 p3 ( 0 , 0 ) = m_mainDirections[i][6 ];
305296 p3 ( 1 , 0 ) = m_mainDirections[i][7 ];
306297 p3 ( 2 , 0 ) = m_mainDirections[i][8 ];
307298
308- FMatrix rotP1 = rotMat * p1;
309- FMatrix rotP2 = rotMat * p2;
310- FMatrix rotP3 = rotMat * p3;
299+ FMatrix rotP1 = invert (storedRot) * p1;
300+ FMatrix rotP2 = invert (storedRot) * p2;
301+ FMatrix rotP3 = invert (storedRot) * p3;
311302
312303 m_mainDirections[i][0 ] = rotP1 ( 0 , 0 );
313304 m_mainDirections[i][1 ] = rotP1 ( 1 , 0 );
@@ -319,7 +310,7 @@ bool Maximas::createStructure ( std::vector< float > &i_fileFloatData )
319310
320311 m_mainDirections[i][6 ] = rotP3 ( 0 , 0 );
321312 m_mainDirections[i][7 ] = rotP3 ( 1 , 0 );
322- m_mainDirections[i][8] = rotP3( 2, 0 );*/
313+ m_mainDirections[i][8 ] = rotP3 ( 2 , 0 );
323314
324315 }
325316
@@ -339,10 +330,13 @@ void Maximas::rotatePeaks()
339330 FMatrix rot;
340331
341332 if (m_doRotate)
342- rot = invert (storedRot);
343- else
344333 rot = storedRot;
334+ else
335+ rot = invert (storedRot);
345336
337+ // std::cout << rot( 0, 0 ) << " " << rot( 0, 1 ) << " " << rot( 0, 2 ) << std::endl;
338+ // std::cout << rot( 1, 0 ) << " " << rot( 1, 1 ) << " " << rot( 1, 2 ) << std::endl;
339+ // std::cout << rot( 2, 0 ) << " " << rot( 2, 1 ) << " " << rot( 2, 2 ) << std::endl;
346340
347341 for ( int i = 0 ; i < m_mainDirections.size (); i++ )
348342 {
@@ -358,7 +352,6 @@ void Maximas::rotatePeaks()
358352 p2 ( 1 , 0 ) = m_mainDirections[i][4 ];
359353 p2 ( 2 , 0 ) = m_mainDirections[i][5 ];
360354
361-
362355 p3 ( 0 , 0 ) = m_mainDirections[i][6 ];
363356 p3 ( 1 , 0 ) = m_mainDirections[i][7 ];
364357 p3 ( 2 , 0 ) = m_mainDirections[i][8 ];
@@ -591,7 +584,7 @@ int zoomS = 300;
591584
592585 wxBoxSizer *pBoxMain = new wxBoxSizer ( wxVERTICAL );
593586
594- wxToggleButton *m_pToggleRotPeaks = new wxToggleButton ( pParent, wxID_ANY,wxT (" Rotate peaks with header" ), wxDefaultPosition, wxSize (zoomS*2 , -1 ) );
587+ wxToggleButton *m_pToggleRotPeaks = new wxToggleButton ( pParent, wxID_ANY,wxT (" Un-rotate peaks with header" ), wxDefaultPosition, wxSize (zoomS*2 , -1 ) );
595588 pParent->Connect ( m_pToggleRotPeaks->GetId (), wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler (PropertiesWindow::OnToggleRotatePeaks) );
596589 pBoxMain->Add ( m_pToggleRotPeaks, 0 , wxFIXED_MINSIZE | wxEXPAND, 0 );
597590
0 commit comments