{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"coregistration.ipynb","provenance":[],"toc_visible":true,"mount_file_id":"1LrAu38-K_ZjOKSZkDLmlfTOjR38stV47","authorship_tag":"ABX9TyPiZkcNQ57aRU7WOSPIv5jW"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"markdown","metadata":{"id":"gyd8tZLembn_"},"source":["# Coregistration"]},{"cell_type":"markdown","metadata":{"id":"On_kC6p_mjxm"},"source":["- Three different images need to be coregistered: EM, 2p structural stack, and 2p video.\n","- 2p structural image is used as reference. EM and 2p video are coregistered to 2p structural image"]},{"cell_type":"code","metadata":{"id":"MY4vuyJCmYNL","executionInfo":{"status":"ok","timestamp":1616646974032,"user_tz":-540,"elapsed":704,"user":{"displayName":"J. Alexander Bae","photoUrl":"","userId":"06779053848267069857"}}},"source":["import numpy as np\n","import pandas as pd\n","\n","from pydrive.auth import GoogleAuth\n","from pydrive.drive import GoogleDrive\n","from google.colab import auth\n","from oauth2client.client import GoogleCredentials"],"execution_count":9,"outputs":[]},{"cell_type":"code","metadata":{"id":"VT2yLztirRA4","executionInfo":{"status":"ok","timestamp":1616647141182,"user_tz":-540,"elapsed":33769,"user":{"displayName":"J. Alexander Bae","photoUrl":"","userId":"06779053848267069857"}}},"source":["auth.authenticate_user()"],"execution_count":12,"outputs":[]},{"cell_type":"code","metadata":{"id":"DVYF9fe3q-X_","executionInfo":{"status":"ok","timestamp":1616647930689,"user_tz":-540,"elapsed":1190,"user":{"displayName":"J. Alexander Bae","photoUrl":"","userId":"06779053848267069857"}}},"source":["gauth = GoogleAuth()\n","gauth.credentials = GoogleCredentials.get_application_default()\n","drive = GoogleDrive(gauth)"],"execution_count":17,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"J7vPpTV2ntk-"},"source":["## EM to 2p structural stack\n","- Affine transformation computed from manually annotated correspondence points.\n","- From $\\mu m$ to $\\mu m$."]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":419},"id":"R3hYBJRFu-7v","executionInfo":{"status":"ok","timestamp":1616648817874,"user_tz":-540,"elapsed":1162,"user":{"displayName":"J. Alexander Bae","photoUrl":"","userId":"06779053848267069857"}},"outputId":"bafe79d3-674a-4ebb-c1a8-b366289f9a9f"},"source":["downloaded = drive.CreateFile({'id': '1E-8BIJ-5gSkGPMs1D_7VUz-05BHB8Tkd'})\n","downloaded.GetContentFile('correspondence_points.csv')\n","correspondence_df = pd.read_csv('correspondence_points.csv')\n","correspondence_df"],"execution_count":29,"outputs":[{"output_type":"execute_result","data":{"text/html":["
\n"," | em_x_nm | \n","em_y_nm | \n","em_z_nm | \n","2p_x_um | \n","2p_y_um | \n","2p_z_um | \n","
---|---|---|---|---|---|---|
0 | \n","343611.4492 | \n","250417.9579 | \n","14958.552610 | \n","185.15625 | \n","228.90625 | \n","182.0 | \n","
1 | \n","355013.9059 | \n","185993.0628 | \n","2590.900730 | \n","194.53125 | \n","225.78125 | \n","113.0 | \n","
2 | \n","286345.4157 | \n","182402.2280 | \n","3763.086764 | \n","139.06250 | \n","229.68750 | \n","107.0 | \n","
3 | \n","289383.5417 | \n","193791.0977 | \n","3976.920274 | \n","140.62500 | \n","231.25000 | \n","118.0 | \n","
4 | \n","442196.8375 | \n","225395.3290 | \n","3789.988336 | \n","266.40625 | \n","221.87500 | \n","155.0 | \n","
... | \n","... | \n","... | \n","... | \n","... | \n","... | \n","... | \n","
507 | \n","304441.2743 | \n","183007.6088 | \n","85893.699400 | \n","146.09375 | \n","153.90625 | \n","126.0 | \n","
508 | \n","240674.3707 | \n","204383.2716 | \n","84512.516840 | \n","94.53125 | \n","164.84375 | \n","147.0 | \n","
509 | \n","238628.4303 | \n","275948.9703 | \n","86287.090170 | \n","89.06250 | \n","175.78125 | \n","221.0 | \n","
510 | \n","264332.4059 | \n","258343.3673 | \n","86435.445200 | \n","110.15625 | \n","166.40625 | \n","200.0 | \n","
511 | \n","250600.1024 | \n","253139.6369 | \n","85827.925000 | \n","100.00000 | \n","168.75000 | \n","195.0 | \n","
512 rows × 6 columns
\n","