Skip to content
Advertisement

How to convert tensor from 2D to 4D

I’m currently working with DICOM files and the TensorFlow IO library for DICOM files seems to throw some errors. So what I was originally doing was this:

JavaScript
JavaScript

Anyways, I instead decided to load the DICOM files with pydicom, which seems to work loading the data into a numpy array. Yet, when I create a tensor from the data, I can’t seem to get it in the correct dimensions:

JavaScript
JavaScript

Ultimately, I do want the (Z, X, Y, D) format for some later parts of the program, but not sure how to get the 2D tensor into that version.

Thanks!

Advertisement

Answer

You could just use numpy.reshape(), e.g.:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement