現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
Can somebody please help me how to convert *.bil files to *.cyt file formats ?
7 ビュー (過去 30 日間)
古いコメントを表示
Surya Gnyawali
2018 年 3 月 21 日
Hi I have a hyperspectral datacube in *.bil format and I need to convert it to *.cyt file format. Can you please help me with this code? Appreciate for the great help.
7 件のコメント
Rik
2018 年 3 月 21 日
If you can provide the file type descriptions, we can help you with implementation. Have you already tried your favorite internet search engine for a converter?
Rik
2018 年 3 月 21 日
OK, so now we have a function to read the .bil files, we need a description of how a .cyt file works. Also, can you select the code and then click the {}Code button? Currently your function is unreadable.
Guillaume
2018 年 3 月 22 日
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Loading a Hyperspectral Cube into Matlab %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Import the header file
[FileName,PathName,FilterIndex] =...
uigetfile({'*.hdr','Hyperspec Header File'},...
'Open Hyperspec Header File');
%%Gets the data from the Header File
fid = fopen([PathName,FileName]);
% fid is file ID
% fgetl gets one line
% char changes cell array to character array
% textscan helps parse around ' ' spaces
% char(Camera.Gain{3}) makes the third cell in Gain into a char array
% str2double converst the string of characters to a double number.
Data.Format = fgetl(fid);
DateStamp = fgetl(fid);
DateStamp = textscan(char(DateStamp),'%s%s%s%s%s%s%s%s',1);
Temp1 = char(DateStamp{3});
Temp2 = char(DateStamp{4});
Temp3 = char(DateStamp{5});
Temp4 = char(DateStamp{6});
Temp5 = char(DateStamp{7});
Temp6 = char(DateStamp{8});
DateStamp = [Temp1(3:length(Temp1)),' ',Temp2,' ',Temp3,' ',Temp4,...
' ',Temp5,' ',Temp6(1:(length(Temp6)-2))];
DataFormat.Samples = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Samples = str2double(char((DataFormat.Samples{3})));
DataFormat.Lines = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Lines = str2double(char((DataFormat.Lines{3})));
DataFormat.Bands = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Bands = str2double(char((DataFormat.Bands{3})));
DataFormat.HeaderOffset = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.HeaderOffset = str2double(char((DataFormat.HeaderOffset{4})));
DataFormat.FileType = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.FileType = ([char((DataFormat.FileType{3})),' ',...
char((DataFormat.FileType{4}))]);
Temp = textscan(char(fgetl(fid)),'%s%s%s%s',1);
Temp2 = str2double(char((Temp{4})));
switch Temp2
case 1
DataFormat.DataType = 'uint8';
case 2
DataFormat.DataType = 'int16';
case 3
DataFormat.DataType = 'int32';
case 4
DataFormat.DataType = 'float32';
case 5
DataFormat.DataType = 'double';
case 9
DataFormat.DataType = 'complex';
case 12
DataFormat.DataType = 'uint16';
end
DataFormat.Interleave = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Interleave = (char((DataFormat.Interleave{3})));
DataFormat.SensorType = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.SensorType = (char((DataFormat.SensorType{4})));
DataFormat.ByteOrder = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.ByteOrder = str2double(char((DataFormat.ByteOrder{4})));
if mod(DataFormat.ByteOrder,2) == 0
DataFormat.ByteOrder = 'ieee-le';
elseif mod(DataFormat.ByteOrder,2) == 1
DataFormat.ByteOrder = 'ieee-be';
end
DataFormat.Units = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.Units = (char((DataFormat.Units{4})));
Junk = fgetl(fid); % We just don't need this line, but we need to read past it.
%%Gets the wavelength data and puts it in a vector
i = 1;
j = 0;
a = [];
while i==1
b = fgetl(fid);
if b == -1
i=0;
elseif b(length(b))=='}'
a = cat(2,a,b(1:(length(b)-1)));
else
a = cat(2,a,b);
end
end
Wavelengths = str2num(a);
fclose(fid); % Closes the file.
clear Temp Temp2 Temp3 Temp4 Temp5 Temp6 a b Junk
%%Import the data file (UI version)
[FileNameData,PathName,FilterIndex] =...
uigetfile({'*.bil','Hyperspec Data File';'*.*','All Files'},...
'Open Hyperspec Data File', PathName) ;
% Set the Data Size
DataSize = [ DataFormat.Lines DataFormat.Samples DataFormat.Bands ];
% Load data with multibandread and assign to variable
HyperDataCube = multibandread([PathName,FileNameData], DataSize,...
DataFormat.DataType,DataFormat.HeaderOffset,...
DataFormat.Interleave, DataFormat.ByteOrder);
Mesh Plot of Data at specific wavelength.
Lambda = 10; % One element of the Wavelength vector
figure(3);mesh(fliplr(squeeze(HyperDataCube(:,:,Lambda))));view(180,90);
title(['Hyperspectral Data: \lambda = ',num2str(Wavelengths(Lambda)),...
' nm'],'FontSize',14);
xlabel('Pixels','FontSize',12);
ylabel('Pixels','FontSize',12);
Guillaume
2018 年 3 月 22 日
File created by Cytospec - date: 17-Mar-2018 , time: 17:30:39
please do not modify this file
INS - IFS Vector 22 + IRscope II
MAN - Bruker
SRC - MAN
BSP - Globar
FIL - open
DET - MCT (microscope)
VEL - 20 kHz
LAS - 15799.1
AQM - double sided fw bw
SNG - automatic
LWN - 397.746
UWN - 994.8992
WVS - 25.9632
NOD - 24
DAT - 09-OCT-2000
TIM - 11:30:00
PHC - Mertz
PHR - 32
PIP -
ZFF - 4
RES - 8
APO - Happ-Genzel
APT - 45
STX - 30
STY - 30
TOS - absorbance
NOS - 8
XDI - 1192
YDI - 1600
SZX - 2400
SZY - 2400
SAM - B1760/98(Buch)
SAF - dry on CaF2
OPN - Peter Lasch
AS1 - dry colon adenocarcinoma sample
AS2 - colon sample, spectrally and spatially interpolated
AS3 - Hunter College, New York
BLO - 1 0 0 0
4 ORG (original data):
data imported as ascii files, date: 10-Oct-2000, time: 15:57:0
spectral interpolation factor: 2, NOD (old): 1323, new NOD: 662, date: 14-Apr-2006, time: 16:16:19
map dimensions (old): 84 x 84, new map dimensions: 42 x 42, date: 14-Apr-2006, time: 16:17:0
spectral interpolation factor: 16, NOD (old): 373, new NOD: 24, date: 17-Mar-2018, time: 17:14:29
2 PRE (preprocessed data):
spectral interpolation factor: 2, NOD (old): 1323, new NOD: 662, date: 14-Apr-2006, time: 16:16:19
map dimensions (old): 84 x 84, new map dimensions: 42 x 42, date: 14-Apr-2006, time: 16:17:0
2 DER (derivative data):
spectral interpolation factor: 2, NOD (old): 1323, new NOD: 662, date: 14-Apr-2006, time: 16:16:19
map dimensions (old): 84 x 84, new map dimensions: 42 x 42, date: 14-Apr-2006, time: 16:17:0
2 DEC (deconvolution data):
spectral interpolation factor: 2, NOD (old): 1323, new NOD: 662, date: 14-Apr-2006, time: 16:16:19
map dimensions (old): 84 x 84, new map dimensions: 42 x 42, date: 14-Apr-2006, time: 16:17:0
Guillaume
2018 年 3 月 22 日
The last text is taken from a .cyt file. I am not familier about this file type.
Guillaume
2018 年 3 月 22 日
Please use Comment on this question rather than spamming your own question with Answers. If people see that the question has already 3 answers, there's less chance they'll look at it and you'll have less chances of getting an answer.
Surya Gnyawali
2018 年 3 月 22 日
編集済み: Guillaume
2018 年 3 月 22 日
% Import the header file
[FileName,PathName,FilterIndex] =...
uigetfile({'*.hdr','Hyperspec Header File'},...
'Open Hyperspec Header File');
%%Gets the data from the Header File
fid = fopen([PathName,FileName]);
% fid is file ID
% fgetl gets one line
% char changes cell array to character array
% textscan helps parse around ' ' spaces
% char(Camera.Gain{3}) makes the third cell in Gain into a char array
% str2double converst the string of characters to a double number.
Data.Format = fgetl(fid);
DateStamp = fgetl(fid);
DateStamp = textscan(char(DateStamp),'%s%s%s%s%s%s%s%s',1);
Temp1 = char(DateStamp{3});
Temp2 = char(DateStamp{4});
Temp3 = char(DateStamp{5});
Temp4 = char(DateStamp{6});
Temp5 = char(DateStamp{7});
Temp6 = char(DateStamp{8});
DateStamp = [Temp1(3:length(Temp1)),' ',Temp2,' ',Temp3,' ',Temp4,...
' ',Temp5,' ',Temp6(1:(length(Temp6)-2))];
DataFormat.Samples = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Samples = str2double(char((DataFormat.Samples{3})));
DataFormat.Lines = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Lines = str2double(char((DataFormat.Lines{3})));
DataFormat.Bands = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Bands = str2double(char((DataFormat.Bands{3})));
DataFormat.HeaderOffset = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.HeaderOffset = str2double(char((DataFormat.HeaderOffset{4})));
DataFormat.FileType = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.FileType = ([char((DataFormat.FileType{3})),' ',...
char((DataFormat.FileType{4}))]);
Temp = textscan(char(fgetl(fid)),'%s%s%s%s',1);
Temp2 = str2double(char((Temp{4})));
switch Temp2
case 1
DataFormat.DataType = 'uint8';
case 2
DataFormat.DataType = 'int16';
case 3
DataFormat.DataType = 'int32';
case 4
DataFormat.DataType = 'float32';
case 5
DataFormat.DataType = 'double';
case 9
DataFormat.DataType = 'complex';
case 12
DataFormat.DataType = 'uint16';
end
DataFormat.Interleave = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Interleave = (char((DataFormat.Interleave{3})));
DataFormat.SensorType = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.SensorType = (char((DataFormat.SensorType{4})));
DataFormat.ByteOrder = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.ByteOrder = str2double(char((DataFormat.ByteOrder{4})));
if mod(DataFormat.ByteOrder,2) == 0
DataFormat.ByteOrder = 'ieee-le';
elseif mod(DataFormat.ByteOrder,2) == 1
DataFormat.ByteOrder = 'ieee-be';
end
DataFormat.Units = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.Units = (char((DataFormat.Units{4})));
Junk = fgetl(fid); % We just don't need this line, but we need to read past it.
%%Gets the wavelength data and puts it in a vector
i = 1;
j = 0;
a = [];
while i==1
b = fgetl(fid);
if b == -1
i=0;
elseif b(length(b))=='}'
a = cat(2,a,b(1:(length(b)-1)));
else
a = cat(2,a,b);
end
end
Wavelengths = str2num(a);
fclose(fid); % Closes the file.
clear Temp Temp2 Temp3 Temp4 Temp5 Temp6 a b Junk
%%Import the data file (UI version)
[FileNameData,PathName,FilterIndex] =...
uigetfile({'*.bil','Hyperspec Data File';'*.*','All Files'},...
'Open Hyperspec Data File', PathName) ;
% Set the Data Size
DataSize = [ DataFormat.Lines DataFormat.Samples DataFormat.Bands ];
% Load data with multibandread and assign to variable
HyperDataCube = multibandread([PathName,FileNameData], DataSize,...
DataFormat.DataType,DataFormat.HeaderOffset,...
DataFormat.Interleave, DataFormat.ByteOrder);
Mesh Plot of Data at specific wavelength.
Lambda = 10; % One element of the Wavelength vector
figure(3);mesh(fliplr(squeeze(HyperDataCube(:,:,Lambda))));view(180,90);
title(['Hyperspectral Data: \lambda = ',num2str(Wavelengths(Lambda)),...
' nm'],'FontSize',14);
xlabel('Pixels','FontSize',12);
ylabel('Pixels','FontSize',12);
if true
% code
end
%------------------------------------------------------------
This link has all the matlab code used on the software "CytoSpec". You may find useful info on these files. Thanks a lot
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Standard File Formats についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)