Numpyarray data stored in .pkl format file. How to get image from this Numpyarray stored in .pkl format?

farah_jabeen: <blockquote>
<p>I have data stored in the NumPy array in .pkl file format. I only had an idea that data consists of low-dose CT DICOM images. But as the data is in array format I don’t know what the original images look like. I am stuck at this point may be my question is also not valid but still, does anybody have knowledge about it. I don’t know whether my question is valid but I I am confused here and I want to get images from it</p>
<p>This is the .pkl format file lowDose_CT.pkl and when I read this file I got the following output</p>
<p>output</p>
</blockquote>
<p>[[array([[[-1000, -1000, -1000, …, -1000, -1000, -1000], [-1000, -1000, -1000, …, -1000, -1000, -1000], [-1000, -1000, -1000, …, -1000, -1000, -1000], …, [-1000, -1000, -1000, …, -1000, -1000, -1000], [-1000, -1000, -1000, …, -1000, -1000, -1000], [-1000, -1000, -1000, …, -1000, -1000, -1000]],…</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/3X/2/8/28de0ad8733d5b9b5d27fb2961c604ea20180d4c.jpeg" alt="abc" data-base62-sha1="5PwOZgVCIWcbU58topOpZftCXww" width="562" height="349"></p>

ptrblck: <p>The numpy array should be storing the actual values (probably radiodensity in HU).<br>
You should be able to use a medical viewer to visualize the data using a specific window.<br>
I’m not sure how this issue is related to PyTorch, so don’t know where you are stuck.</p>

farah_jabeen: <aside class="quote no-group" data-username="ptrblck" data-post="2" data-topic="156092">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/48/1823_2.png" class="avatar"> ptrblck:</div>
<blockquote>
<p>not sure how this issue is related to PyTorch, so don’t know where you are stuck.</p>
</blockquote>
</aside>
<p>So, does it means these NumPy arrays(array values) in .pkl format files can be visualized using a medical viewer and I can view images? Because I only have these.pkl files stored in NumPy array and I want to implement preprocessing techniques like cropping/padding/extract patches and used them for 3D CNN models for training purposes for classification task</p>

ptrblck: <aside class="quote no-group" data-username="farah_jabeen" data-post="3" data-topic="156092">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/farah_jabeen/48/46119_2.png" class="avatar"> farah_jabeen:</div>
<blockquote>
<p>So, does it means these NumPy arrays(array values) in .pkl format files can be visualized using a medical viewer and I can view images?</p>
</blockquote>
</aside>
<p>I don’t know how medical image viewers would handle the missing voxel spacing etc., but would guess default values would be used. A simple approach would be to grab a single slice and visualize it with <code>matplotlib</code>.</p>
<aside class="quote no-group" data-username="farah_jabeen" data-post="3" data-topic="156092">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/farah_jabeen/48/46119_2.png" class="avatar"> farah_jabeen:</div>
<blockquote>
<p>Because I only have these.pkl files stored in NumPy array and I want to implement preprocessing techniques like cropping/padding/extract patches</p>
</blockquote>
</aside>
<p>These preprocessing steps should directly work on the numpy array or tensor and wouldn’t need a special viewer.</p>
<aside class="quote no-group" data-username="farah_jabeen" data-post="3" data-topic="156092">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/farah_jabeen/48/46119_2.png" class="avatar"> farah_jabeen:</div>
<blockquote>
<p>and used them for 3D CNN models for training purposes for classification task</p>
</blockquote>
</aside>
<p>Same here: you should be able to directly use the array by transforming it into a PyTorch tensor and by passing it to a model.</p>

farah_jabeen: <p>Thank you dear i understand <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>