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

Modifying Pixel Data with Multiple frames #1

Open
ekin-remedy opened this issue Jun 10, 2022 · 4 comments
Open

Modifying Pixel Data with Multiple frames #1

ekin-remedy opened this issue Jun 10, 2022 · 4 comments

Comments

@ekin-remedy
Copy link

ekin-remedy commented Jun 10, 2022

Hi @WoonchanCho ,

I came across your dicomedit library while looking for Javascript libraries that can do DICOM pixel data manipulation. FIrst of all, it looks great and works really well! I have one question: Does this library support modifying pixels on multiframe dicoms? I used your example dicom anonymizer app (https://testanonymizer.web.app/) and it seemed like the alterPixels only draws the rectangle on the first frame for a multiple frame dicom.

@WoonchanCho
Copy link
Owner

Hi @ekin-remedy, thank you for your suggestion. I didn't test with multiframe DICOMs. Do you have publicly an available multiframe DICOM or the link to it? I'd like to have one that use to develop and test. Thank you so much.

@ekin-remedy
Copy link
Author

ekin-remedy commented Jun 10, 2022

@WoonchanCho Pydicom has a bunch of test dicom files here. This has some multiframe DICOMs as well (e..g OBXXXX1A_2frame.dcm, SC_rgb_2frame.dcm, SC_rgb_expb_2frame.dcm)

These files can be useful for testing the code with different DICOM files (various compressions, missing data, etc.) as well. Thank you!

@ekin-remedy
Copy link
Author

I think you should be able to get the masking to work with multiple frames by looping over the number of frames in the pixel manipulation logic (in PixelModifier's drawRectangle method). So something like:

for (let frame = 0; frame < numFrames; ++frame) {
    const frameStart = frame * width * height * samplesPerPixel;
    for (let i = top; i < bottom; ++i) {
        const offset = (width * i + left) * samplesPerPixel + frameStart;
        const limit = offset + (right - left) * samplesPerPixel;
        for (let j = offset; j < limit; ++j) {
             pixelData[j] = darkestValue;
        }
    }
}

where numFrames is the NumberOfFrames field (0028, 0008) of the dicom.

@WoonchanCho
Copy link
Owner

@ekin-remedy Looks great. Thank you so much for your support and suggestion. It looks good to me. I will try to update and test soon and let you know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants