convert mat file to image

14 views (last 30 days)
bruno
bruno on 12 Dec 2022
Commented: Image Analyst on 15 Dec 2022
Hello! I have a mat file attached. I have to perform classification problem later on using FFT+ Alexnet+transfer learning. So for the input in alexnet I want my data to be 2D from 1D as an image so I can implement further. What shall I do?

Accepted Answer

Image Analyst
Image Analyst on 12 Dec 2022
s = load('100.mat')
s = struct with fields:
trial: 100 disp: 0 SAMPLES2READ: 648000 TIME: [0 0.0028 0.0056 0.0083 0.0111 0.0139 0.0167 0.0194 0.0222 0.0250 0.0278 0.0306 0.0333 0.0361 0.0389 0.0417 0.0444 0.0472 0.0500 0.0528 0.0556 0.0583 0.0611 0.0639 0.0667 0.0694 0.0722 0.0750 0.0778 0.0806 0.0833 0.0861 0.0889 … ] ATRTIMED: [2266×1 double] ANNOTD: [2266×1 double] i: 1 TR: [100 101 102 103 104 105 106 107 108 109 111 112 113 114 115 116 117 118 119 121 122 123 124 200 201 202 203 205 207 208 209 210 212 213 214 215 217 219 220 221 222 223 228 230 231 232 233 234] Path: 'MIT-BIH_MAT\' LTR: 48 M: [648000×2 double]
There are a lot of variables in there. Which should turn into an image, and how?
  13 Comments
Walter Roberson
Walter Roberson on 15 Dec 2022
What are the possibilities? Which possibilities have advantages or disadvantages?
  • constant 0; constant 255; constant 127 or 128
  • copy red channel; copy green channel
  • some linear combination of red and green channel
None of the above add new information.
If you were training, then some of the possibilities would run the risk that the training would waste time chasing apparent information that was not really there.
But you are not training: you are using a pre-trained AlexNet for classification purposes. So then question then becomes which of those possibilities lead to the best predictions from that pre-trained network.
I think you will have a very difficult time getting anything useful out of the pre-trained alexnet for your purposes. I imagine, though, that your project assignment is to try it anyhow and see what you can do anyhow, and then analyze the failures, to demonstrate that you understand how the network is intended to work and talk about why it did not work for you.
Image Analyst
Image Analyst on 15 Dec 2022
(Expand to see Walter's comment above.)
If you're retraining Alexnet (transfer learning by replacing some layers), then all you have is info for two color channels. You can put them into whatever color channel you want but that still leaves one color channel that you have to create. I created it as just all zeros. I could be wrong but I think that with all zeros it might learn more quickly to ignore that channel completely. And that's what we need. We need all the weights for pixels in the 3rd channel to be zero since there is no additional information in that channel. The network should learn, during the retraining, to ignore that channel.

Sign in to comment.

More Answers (0)

Categories

Find more on Image Data Workflows in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!