How can I load GDS II into matlab?

56 Ansichten (letzte 30 Tage)
Reem
Reem am 2 Jun. 2014
Bearbeitet: Walter Roberson am 1 Nov. 2024
I want to load GDS II layout format into matlab in the form of a matrix, how can I do that?

Akzeptierte Antwort

José-Luis
José-Luis am 2 Jun. 2014
  1. The hard way: find out how the GDSII binary is structured and read it directly into Matlab.
  2. The compromise way: Use a GDSII to ascii converter (Google will find you one in less than 30s) and then read that into Matlab. importdata(), textscan(), are then your friends.
  3. The easy way: Look in the file exchange to see if anyone has done that before
  7 Kommentare
Andrew Davies
Andrew Davies am 9 Mai 2024
Bearbeitet: Walter Roberson am 1 Nov. 2024
Yes, you can loop through the elements. See example below. The key command is numel(GDS_structure) which gives you the number of elements.
% Read GDS file
GDS_Library = read_gds_library(filename); % file must be in the same folder as this matlab script
%treeview(GDS_Library) % shows the structures
GDS_box = bbox(GDS_Library); % Calculates the rectangular bounding box of a gds_structure object.
Point_units = get(GDS_Library,'uunit'); % (m) defualt is 10-6 m = 1 um
GDS_structure = GDS_Library(1); % setting the 1st structure equal to GDS_structure which can have multiple elements
% Number_of_elements = numel(GDS_Library);
Number_of_elements = numel(GDS_structure); % or size(GDS_structure(:),2) gives the number of elements in structure or Library
% Recover the polygon points for each element
for i= 1:Number_of_elements
GDS_elements = GDS_structure(i); % Get each element in the structure
xy_recovered = GDS_elements.xy; % or xy_recovered = get(GDS_elements, 'xy'), sometimes cell array sometimes numeric array
%xy_recovered = xy_recovered{1};
%xy_point{i} = xy_recovered; % This is a matlab cell structure. Normal matlab rules apply to it.
if iscell(xy_recovered)==1
xy_point{i}=cell2mat(xy_recovered); % This is a matlab cell structure
elseif isnumeric(xy_recovered) == 1
xy_point{i} = xy_recovered; % This is a matlab cell structure
else
whos xy_recovered
end
end
Courtney
Courtney am 1 Nov. 2024
Hello I guess i never got notified of you response but I had found and made numel work at the time. Your solution to catch the cell vs numeric format is really helpful though, I was just catching and skipping otherwise, since mostly the errors were empty anyways.
I found this post again in trying to solve a new problem I'm running into. Im still importing preexisting gds, but now it's a set of tiered cells (many separate gds structures within the library). I can pull out the number of structures and then nest to get all the elements but it doesnt capture their global coordinates relative to the mask. So all the structures are placed at 0,0. Is there a way to pull the coordinate of each each structure relative to the whole mask? bbox didnt seem to help, they still mostly originated at 0,0.
val is a GDSII library:
Library name : Absorber.DB
Database unit : 5e-08 m
User unit : 1e-06 m
Structures : 21
1 ... Absorber_Overlay (16)
2 ... 6mm_die (21)
3 ... Alignment_marks_3 (192)
.... etc
gds = read_gds_library(path); %read in the gyro gds
%Point_units = get(gds,'uunit');
%Struct = gds(1); %extract the structure
%ElNum = numel(Struct);
ElNumTot = numel(gds); %det how many elements (shapes) w/in the set of structure
LCC_XY=[];
%cnt=0;
for kk = 1:length(gds)
Struct = gds(kk); %extract the structure
elTemp = numel(Struct);
bboxStruct = bbox(Struct); %
xStart=0;%bboxStruct(1)*1e3;
yStart=0;%bboxStruct(2)*1e3;
for ii=1:elTemp
LCC = Struct(ii);
xy_recovered = LCC.xy; %xy_recovered = get(GDS_elements, 'xy');
%xy_recovered = xy_recovered{1};
%xy_point{i} = xy_recovered; % This is a matlab cell structure. Normal matlab rules apply to it.
if iscell(xy_recovered)==1
LCC_XY{ii}=cell2mat(xy_recovered).*1e3; % This is a matlab cell structure
elseif isnumeric(xy_recovered) == 1
LCC_XY{ii} = xy_recovered.*1e3; % This is a matlab cell structure
else
whos xy_recovered
end
% try
% LCC_XY = xy_recovered{1}*1e3+[xStart,yStart];
LCC_out_discrete = round(LCC_XY{ii}/grid)*grid; % round to discrete points on the grid
%catch
%skip
% end
end
end

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by