Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image offset and oriented incorrectly #1459

Closed
LeoReubelt opened this issue Jul 28, 2023 · 7 comments · Fixed by #1509
Closed

Image offset and oriented incorrectly #1459

LeoReubelt opened this issue Jul 28, 2023 · 7 comments · Fixed by #1509
Labels
bug Something isn't working
Milestone

Comments

@LeoReubelt
Copy link

I have attached a series that I am testing with. When I open it, the image is oriented offset incorrectly. When I load the files, the screen is blank. But if I zoom out, eventually, it shows up. This file used to work in a previous version of dwv.
dicom_test.zip

@ivmartel ivmartel added the question Further information is requested label Aug 4, 2023
@ivmartel ivmartel added this to the 0.33.0 milestone Aug 4, 2023
@ivmartel
Copy link
Owner

I need to check the flips the code does when creating a view (see application.js#L1552), its logic does not seem to handle your data...

@LeoReubelt
Copy link
Author

LeoReubelt commented Aug 16, 2023

If I comment out that entire section that performs the flipping (effectively just removes layerGroup.flipScaleZ()), the image shows up in the correct location and correct orientation, but when I zoom, it flips. Does that indicate anything to you?

@LeoReubelt
Copy link
Author

LeoReubelt commented Aug 17, 2023

Thanks @ivmartel. I have a few files that have this problem. I made the following change to #addViewLayer(dataIndex, dataViewConfig) in application.js, which fixes it for my test cases, but I don't know the results for all orientations. I am putting it here in case it helps.

// view layer scale
// only flip scale for base layers
if (isBaseLayer) {
  if (typeof dataViewConfig.orientation !== "undefined") {
    if (major === 0 || major === 2) {
      // scale flip Z for oriented views...
      layerGroup.flipScaleZ();
    } else {
      viewLayer.setScale(layerGroup.getScale());
      if (typeof drawLayer !== "undefined") {
        drawLayer.setScale(layerGroup.getScale());
      }
    }
  } else {
    //BEGIN ADDED ******************************************
    const orientation = imageGeometry.getOrientation();
    if (
      orientation.get(0, 0) < 0 ||
      orientation.get(0, 1) < 0 ||
      orientation.get(0, 2) < 0
    ) {
      layerGroup.flipScaleX();
    }

    if (
      orientation.get(1, 0) < 0 ||
      orientation.get(1, 1) < 0 ||
      orientation.get(1, 2) < 0
    ) {
      layerGroup.flipScaleY();
    }
    if (
      orientation.get(2, 0) < 0 ||
      orientation.get(2, 1) < 0 ||
      orientation.get(2, 2) < 0
    ) {
      layerGroup.flipScaleZ();
    }
    //END ADDED **********************************

    if (major === 0) {
      // scale flip Z for sagittal and undefined target orientation

      //COMMENTED OUT ****************************
      //layerGroup.flipScaleZ();
    } else {
      viewLayer.setScale(layerGroup.getScale());
      if (typeof drawLayer !== "undefined") {
        drawLayer.setScale(layerGroup.getScale());
      }
    }
  }
} else {
  viewLayer.setScale(layerGroup.getScale());
  if (typeof drawLayer !== "undefined") {
    drawLayer.setScale(layerGroup.getScale());
  }
}

@LeoReubelt
Copy link
Author

LeoReubelt commented Aug 23, 2023

@ivmartel - I was modifying a fork at... v0.32.e. Is seems to work with all my test cases. All the changes (except the creation of new flip functions) are in app.js. The changes are in the same place where the flips occur along with a few helper functions. it won't work for image patient orientations that have decimal values, but maybe the logic will still help.

@ivmartel
Copy link
Owner

Thanks for all this. How did you validate the code? Do you have data for every possible orientation?

@LeoReubelt
Copy link
Author

LeoReubelt commented Aug 24, 2023

At this stage it was just round 1 validation.

  1. assembled a group of files with different orientations - i think i covered them all, but i would have to double check that.
  2. visually checked that the image was in the correct location on load and in each mpr orientation.
  3. i compared some of them with osyrix to make sure the orientation was correct
  4. i used the zoom/pan tools with some of them to make sure everything worked there. in one of my earlier attempts, when i tried to pan, the image filpped.

I think we do have data for every orientation but only orientations with -1's, 1's, and 0's. if you need files, i can see if i can get them for you.

@ivmartel
Copy link
Owner

Yes, if you can share the data, that would be very helpful.

@ivmartel ivmartel added bug Something isn't working and removed question Further information is requested labels Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants