{"id":1121,"date":"2011-02-26T00:08:05","date_gmt":"2011-02-26T00:08:05","guid":{"rendered":"http:\/\/labrigger.com\/blog\/?p=1121"},"modified":"2011-02-26T00:08:05","modified_gmt":"2011-02-26T00:08:05","slug":"matlab-code-for-designing-collection-optics-for-2p-scopes","status":"publish","type":"post","link":"http:\/\/labrigger.com\/blog\/2011\/02\/26\/matlab-code-for-designing-collection-optics-for-2p-scopes\/","title":{"rendered":"MATLAB code for designing collection optics for 2p scopes"},"content":{"rendered":"<p align=\"center\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/labrigger.com\/blog\/wp-content\/uploads\/2011\/02\/colloptics.png\" alt=\"\" title=\"Collection optics, fig. 3.13 from the Tsai book chapter mentioned in the post\" width=\"600\" height=\"321\" class=\"aligncenter size-full wp-image-1126\" srcset=\"http:\/\/labrigger.com\/blog\/wp-content\/uploads\/2011\/02\/colloptics.png 600w, http:\/\/labrigger.com\/blog\/wp-content\/uploads\/2011\/02\/colloptics-300x160.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>The Tsai <a href=\"http:\/\/www-physics.ucsd.edu\/neurophysics\/publications\/CRC_chapter_3.pdf\">book chapter<\/a> from Ron Frostig&#8217;s CRC book is a great resource for <a href=\"http:\/\/labrigger.com\/blog\/2010\/09\/23\/building-a-2-photon-microscope\/\">building your own 2p microscope<\/a>. In section 3.3.7.2, they describe how to design the collection optics. They use a straightforward single lens design, lay out the optics equations, and show a family of curves for several variables (Fig. 3.14). They do an excellent job of giving the reader an intuitive feel for the engineering compromises inherent in these systems.<\/p>\n<p>I&#8217;ve found myself repeatedly going through these calculations for different magnification factors. Or  &#8220;minification&#8221; factors, as is typically the case, since the back aperture of the objective is imaged onto the PMT, which is typically about a third to a quarter of the size.<\/p>\n<p align=\"center\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/labrigger.com\/blog\/wp-content\/uploads\/2011\/02\/coll2.png\" alt=\"\" title=\"A family of curves for collection lenses of different focal lengths. The x and y axes read out L1 and L2. The black dots indicate the positions to achieve a magnification factor of 0.31. The MATLAB code in the post was used to generate this figure.\" width=\"536\" height=\"453\" class=\"aligncenter size-full wp-image-1127\" srcset=\"http:\/\/labrigger.com\/blog\/wp-content\/uploads\/2011\/02\/coll2.png 536w, http:\/\/labrigger.com\/blog\/wp-content\/uploads\/2011\/02\/coll2-300x253.png 300w\" sizes=\"auto, (max-width: 536px) 100vw, 536px\" \/><\/p>\n<p>In order to save time, I wrote a tiny MATLAB program to reproduce Fig 3.14 and overlay points indicating where to place the optics in order to have a particular magnification factor. I used it to generate the figure above.<\/p>\n<pre><font size=0>\r\n%% Dist_cl_pmt, dist_obj_cl, f_cl\r\n% Eqn. 3.18 from Tsai et al. 2009 (CRC);\r\n% dist_cl_pmt = (dist_obj_cl * f_cl) \/ (dist_obj_cl - f_cl)\r\n% Below, for brevity, we use L1 = dist_obj_cl\r\n% Below, for brevity, we use L2 = dist_cl_pmt\r\n\r\n% Make a family of curves relating these quantities.\r\nf_cl = 5:5:50; % Collection lens focal lengths, in mm.\r\nL1 = 50:1:250; % dist_obj_cl\r\nmag = 0.24; % Magnification factor.\r\n\r\nfor f=1:numel(f_cl)\r\n    for L=1:numel(L1)\r\n        L2(f,L) = (L1(L)*f_cl(f))\/(L1(L) - f_cl(f));\r\n    end\r\n    L1m(f) = (f_cl(f)\/mag) + f_cl(f);\r\n    magloc(f)=locateVal(L1m(f),L1);\r\n    L2m(f) = L2(f,magloc(f));\r\nend\r\n\r\nfor f=1:numel(f_cl)\r\n    M{f}=num2str(f_cl(f)); % Labels for the different mag lines\r\nend\r\nfigure\r\nplot(L1,L2);\r\nxlabel('L_1: Distance from objective back plane to collection lens (mm)')\r\nylabel('L_2: Distance from collection lens to PMT (mm)')\r\naxis([50 250 0 200])\r\nlegend(M,'Location','NorthEast')\r\nlegend('boxoff')\r\ntitle(sprintf('Relation between L_1 and L_2 for different f_C_L, indicating positions for mag=%g',mag))\r\nhold on\r\nplot(L1m,L2m,'o')\r\nhold off\r\n<\/font>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p align=\"center\">\n<p>The Tsai <a href=\"http:\/\/www-physics.ucsd.edu\/neurophysics\/publications\/CRC_chapter_3.pdf\">book chapter<\/a> from Ron Frostig&#8217;s CRC book is a great resource for <a href=\"http:\/\/labrigger.com\/blog\/2010\/09\/23\/building-a-2-photon-microscope\/\">building your own 2p microscope<\/a>. In&#8230;<\/p>\n<div class=\"read-more\"><a href=\"http:\/\/labrigger.com\/blog\/2011\/02\/26\/matlab-code-for-designing-collection-optics-for-2p-scopes\/\">Read More<\/a><\/div><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[21,26,15],"class_list":["post-1121","post","type-post","status-publish","format-standard","hentry","category-software","tag-imaging","tag-matlab","tag-optics"],"_links":{"self":[{"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/posts\/1121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/comments?post=1121"}],"version-history":[{"count":7,"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/posts\/1121\/revisions"}],"predecessor-version":[{"id":1130,"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/posts\/1121\/revisions\/1130"}],"wp:attachment":[{"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/media?parent=1121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/categories?post=1121"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/tags?post=1121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}