forked from JCMSK/jcmsk.github.io
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathguidelines.html
More file actions
564 lines (460 loc) · 29.8 KB
/
guidelines.html
File metadata and controls
564 lines (460 loc) · 29.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
<!-- !!! IMPORTANT: Never change position and name of this file because it got linked to the perspective paper !!!-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>ORMIR - Guidelines</title>
<meta content="" name="description">
<meta content="" name="keywords">
<!-- Favicons -->
<link href="assets/img/favicon.png" rel="icon">
<link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet">
<!-- Vendor CSS Files -->
<link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
<link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
<link href="assets/vendor/glightbox/css/glightbox.min.css" rel="stylesheet">
<link href="assets/vendor/remixicon/remixicon.css" rel="stylesheet">
<link href="assets/vendor/swiper/swiper-bundle.min.css" rel="stylesheet">
<!-- Template Main CSS File -->
<link href="assets/css/style.css" rel="stylesheet">
<!-- =======================================================
* Template Name: Tempo
* Updated: Jan 09 2024 with Bootstrap v5.3.2
* Template URL: https://bootstrapmade.com/tempo-free-onepage-bootstrap-theme/
* Author: BootstrapMade.com
* License: https://bootstrapmade.com/license/
======================================================== -->
</head>
<body>
<!-- ======= Header ======= -->
<header id="header" class="fixed-top header-inner-pages">
<div class="container d-flex align-items-center justify-content-between">
<!-- <h1 class="logo"><a href="index.html">ORMIR</a></h1> -->
<!-- Uncomment below if you prefer to use an image logo -->
<a href="index.html" class="logo"><img src="assets/img/logo.png" alt="" class="img-fluid"></a>
<nav id="navbar" class="navbar">
<ul>
<li class="dropdown"><a href="#"><span>About us</span> <i class="bi bi-chevron-down"></i></a>
<ul>
<li><a href="motivation.html">Why a community</a></li>
<li><a href="members.html">Who we are</a></li>
<li><a href="groups.html#">Working groups</a></li>
<li><a href="boards.html">Advisors & Outreach</a></li>
</ul>
</li>
<li class="dropdown"><a class="nav-link" href="#">
<span>Code</span>
<i class="bi bi-chevron-down"></i></a>
<ul>
<li><a href="software.html">Software</a></li>
<li><a href="templates.html">Templates</a></li>
<li><a href="guidelines.html">Guidelines</a></li>
</ul>
</li>
<li class="dropdown"><a class="nav-link" href="#">
<span>Data</span>
<i class="bi bi-chevron-down"></i></a>
<ul>
<li><a href="datasets.html">Datasets</a></li>
<li><a href="policies.html">Policies</a></li>
</ul>
</li>
<li class="dropdown"><a class="nav-link" href="#">
<span>Outreach</span>
<i class="bi bi-chevron-down"></i></a>
<ul>
<li><a href="publications.html">Publications</a></li>
<li><a href="events.html">Events</a></li>
<li><a href="funding.html">Funding</a></li>
</ul>
</li>
<li class="dropdown"><a class="nav-link" href="#">
<span>Joining & Q</span>
<i class="bi bi-chevron-down"></i></a>
<ul>
<li><a href="newcomers.html">I want to join!</a></li>
<li><a href="contact.html">Questions?</a></li>
</ul>
</li>
</ul>
<i class="bi bi-list mobile-nav-toggle"></i>
</nav><!-- .navbar -->
</div>
</header><!-- End Header -->
<!-- ======= accordion ======= -->
<section>
<div class="container">
<!-- Title -->
<div class="section-title">
<h2>Coding guidelines</h2>
</div>
<div class="section-sub-title">
Here are our guidelines for <a href="#code">code</a>, <a href="#data">data</a>, and <a href="#publications">publications</a>
</div>
<br>
<br>
<br>
<!-- Q&A - Accordion -->
<div class="row">
<div class="col-md-12 offset-md-0">
<!-- Trick to jump at the top of the title (not bottom) for internal links -->
<span class="anchor"></span>
<h4>Python code</h4>
<!-- Python code style ----------------------------------->
<div class="accordion-container">
<!-- <div id="code-style"></div> added above to avoid the scroll offset problem -->
<button class="accordion" id="code-style">
What Python <i>code</i> style do I use?
</button>
<div class="answer">
We follow the <a class="reference external" href="https://www.python.org/dev/peps/pep-0008/"> Style Guide for Python Code</a>. In summary:
<br>
<br>
<h6 style="color:#90bc00">Naming Style</h6>
<ul>
<li>
Variables, functions, methods, modules, packages:
<br>
<code-text>lower_case_with_underscores</code-text>
</li>
<li>
Constants:
<br>
<code-text>ALL_CAPS_WITH_UNDERSCORES</code-text>
</li>
<li>
Classes and exceptions:
<br>
<code-text>CapWords</code-text>
</li>
</ul>
<br>
<h6 style="color:#90bc00">Indentation</h6>
<ul>
<li>
4 spaces or 1 tab
</li>
</ul>
<br>
<h6 style="color:#90bc00">Space</h6>
<ul>
<li>
Leave space between operators in case of assignment and arithmetic operations:
<br>
<code-text>var = 4</code-text>
</li>
<li>
Leave space after a comma:
<br>
<code-text>var_1, var_2 = get_values(num_1, num_2)</code-text>
</li>
</ul>
<br>
<h6 style="color:#90bc00">Comments</h6>
<ul>
<li>
Comments are introduced by <code-text>#</code-text> positioned above the code they refer to, and they are indented to align with the code are commenting on:
<br>
<code-text># assign variable</code-text>
<br>
<code-text>a = 5</code-text>
<br>
<i>Why are comments important?</i> As part of a community, we want to write code that can be readable and reusable by others. Let's be generous and precise with our comments!
</li>
</ul>
</div>
</div>
<!-- How do I quickly translate existing code to Python? ----------------------------------->
<div class="accordion-container">
<button class="accordion" id="translate">
How do I quickly translate existing code to Python?
</button>
<div class="answer">
If you already know Python: ChatGPT! Example of command:
<br>
<br>
<code-text>translate the following code from Matlab to Python: [paste your code]</code-text>
<br>
<br>
<i>Important</i>: Double-check the content of ChatGPT output!
<br>
<br>
If you don't know Python, team up with some ORMIR community members who know Python and work on the translation together!
</div>
</div>
<br>
<h4>Python documentation</h4>
<!-- Python documentation style (docstrings) ----------------------------------->
<div class="accordion-container" id="docstrings">
<button class="accordion" id="docstrings">
What Python <i>documentation</i> style (docstrings) do I use?
</button>
<div class="answer">
We use <a class="reference external" href="https://numpydoc.readthedocs.io/en/latest/format.html">Numpy style docstrings</a> to document our code.
Docstrings describe functionalities and parameters of the subsequent code and are enclosed in triple quotes (<code-text>"""..."""</code-text>).
They are typically placed at the beginning of the module, class, function, or method they describe. Here is the example of Numpy style docstrings for functions:
<br>
<code-text>
<br>
def my_function (input1, input2):
<br>
<br>
"""This functions does ...
<br>
<br>
Parameters
<br>
----------
<br>
input_1 : type
<br>
Description of the parameter `input_1`
<br>
input_2 : type
<br>
Description of the parameter `input_2`
<br>
<br>
Returns
<br>
-------
<br>
output: int
<br>
Description of the variable `output`
<br>
"""
<br>
<br>
# function body
<br>
return output
</code-text>
<br>
<br>
The documentation is between the header and the body, and it contains at least the following sections:
<ul>
<li>
Description: An explanation of what the function does
</li>
<li>
Parameters: A description of each parameter the function accepts, including name, data type, definition, and default values
</li>
<li>
Returns: A description of the values returned by the function, including name, data type, definition, and any special cases
</li>
</ul>
You can find a complete description of Numpy style docstrings on <a class="reference external" href="https://numpydoc.readthedocs.io/en/latest/format.html">the Numpy website</a>
</div>
</div>
<!-- How do I create Numpy-style documentation fast?----------------------------------->
<div class="accordion-container">
<button class="accordion" id="docstrings-fast">
How do I create Numpy-style documentation (docstrings) fast?
</button>
<div class="answer">
With ChatGPT! Example of command:
<br>
<br>
<code-text>write docstrings in Numpy style for the following function: [paste your function]</code-text>
<br>
<br>
<i>Important</i>: Double-check the content of ChatGPT output and correct wherever needed!
</div>
</div>
<!-- How do I publish documentation automatically using Read the Docs? ----------------------------------->
<div class="accordion-container">
<button class="accordion" id="readthedocs">
How do I publish documentation <i>automatically</i> using Read the Docs?
</button>
<div class="answer">
<a href="https://docs.readthedocs.io/en/stable/">Read the Docs</a> is a tool to genereate code from docstrings and to host and publish documentation on the web.
To learn how to use Read the Docs follow their step-by-step <a href="https://docs.readthedocs.io/en/stable/tutorial/index.html">tutorial</a>.
An excellent example of Read the Docs is the <a href="https://ciclope.readthedocs.io/en/"> documentation</a> of Ciclope.
</div>
</div>
<!-- How do I publish documentation manually using Sphynx? ----------------------------------->
<div class="accordion-container">
<button class="accordion" id="sphynx">
How do I publish documentation <i>manually</i> using Sphynx?
</button>
<div class="answer">
<a href="https://www.sphinx-doc.org/en">Sphynx</a> is a tool to write and generate documentation from docstrings.
You can find guidelines on how to use Sphynx <a href="assets/documents/ORMIR_Sphinx_SOP.pdf">here</a>
</div>
</div>
<!-- How do I create a website using Jupyter Book? ----------------------------------->
<div class="accordion-container">
<button class="accordion" id="jupyter-book">
How do I create a website using Jupyter Book?
</button>
<div class="answer">
You can find comprehensive guidelines and a template on the <a href="https://jupyterbook.org/en/stable/intro.html">Jupyter Book website</a>. In a nutshell:
<ol>
<li> For each website page, create one <code-text>.md</code-text> or <code-text>.ipynb</code-text> file and write the content using markdown</li>
<li> Create a <code-text>_toc.yml</code-text> and a <code-text>_config.yml</code-text> files (see examples <a href="https://jupyterbook.org/en/stable/start/create.html#anatomy-of-a-jupyter-book">here</a>)</li>
<li> Install Jupyter Book with the command <code-text>pip install jupyter-book</code-text></li>
<li> Create your book with the command <code-text>jupyter-book build book_name</code-text>
</ol>
The created <code-text>.html</code-text> files will be in the folder <code-text>_build/html</code-text>
</div>
</div>
<!-- How do I deploy my Jupyter Book website on GitHub using CI? ----------------------------------------------------->
<div class="accordion-container">
<button class="accordion" id="jupyter-book-CI">
How do I deploy my Jupyter Book website on GitHub using CI?
</button>
<div class="answer">
CI (Continuous Integration) is a tool that allows you to automate procedures, and in GitHub it is called <i>Actions</i>.
Deploying a Jupyter Book website using Actions is very convenient because it automates the building process, ensuring that your site is continuously and seamlessly updated with every change pushed to the repository. You can find detailed information on how to deploy a Jupyter Book website using Actions <a href="https://jupyterbook.org/en/stable/publish/gh-pages.html">here</a>.
Briefly:
<ol>
<li> Make sure that your repository contains all the website content files, (that is, <code-text>.md</code-text> and/or <code-text>.ipynb</code-text> files, together with figures, etc.), <code-text>_config.yml</code-text> and <code-text>_toc.yml</code-text>. Note: You do <i>not</i> need to push the <code-text>_built</code-text> folder because GitHub Action will create the <code-text>.html</code-text> files of your website
</li>
<li> In the same repository, add the following files from
<a href="https://github.com/ORMIRcommunity/templates/tree/main/github_actions_jupyter_book">this</a> ORMIR template folder:
<a href="https://github.com/ORMIRcommunity/templates/blob/main/github_actions_jupyter_book/requirements.txt">requirements.txt</a>,
<a href="https://github.com/ORMIRcommunity/templates/blob/main/github_actions_jupyter_book/.nojekyll">.nojekyll</a>, and
<a href="https://github.com/ORMIRcommunity/templates/blob/main/github_actions_jupyter_book/.github/workflows/ci.yml">.github/workflows/ci.yml</a> (note that <code-text>.nojekyll</code-text> and <code-text>.github/workflows/ci.yml</code-text> are hidden files)
</li>
<li>Go to your GitHub repository on GitHub.com. In the top bar, click on <code-text>Settings</code-text>, and in the appearing left panel, click on <code-text>Pages</code-text>. Under <code-text>Build and deployment</code-text>, <code-text>Source</code-text>, select <code-text>GitHub Actions</code-text>
</li>
<li>Every time you push new content to the repository, the book will be automatically created and the new <code-text>.html</code-text> files will be automatically deployed to your website. You can follow the progress by clicking <code-text>Actions</code-text> on the top bar of the GitHub repository
</ol>
</div>
</div>
<br>
<h4>Code license</h4>
<!-- What license do I use? ----------------------------------->
<div class="accordion-container">
<button class="accordion" id="license-code">
What license do I use for my code?
</button>
<div class="answer">
You can choose a permissive license (e.g. BDS, MIT, Apache) or a copyleft license (e.g. GNU GPL, Mozilla).
If you are not familiar with open-source licenses, you can browse
<a class="reference external" href="https://choosealicense.com/licenses/">choosealicense.com</a>,
read the paper
<a class="reference external" href="https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1002598">A Quick Guide to Software Licensing for the Scientist-Programmer</a>,
or watch
<a class="reference external" href="https://www.youtube.com/watch?v=GlAnKGBnhFY">this video</a> (from minute 4)
</div>
</div>
<br>
<h4>Jupyter notebook</h4>
<!-- What are Jupyter notebooks useful for? ----------------------------------->
<div class="accordion-container">
<button class="accordion" id="jupyter-useful">
What are Jupyter notebooks useful for?
</button>
<div class="answer">
Jupyter notebooks are useful not only to draft code, but also to create use cases, demos, or examples for Python packages
</div>
</div>
<!-- How do I structure a Jupyter notebook? ----------------------------------->
<div class="accordion-container">
<button class="accordion" id="jupyter-structure">
How do I structure a Jupyter notebook?
</button>
<div class="answer">
We created a Jupyter notebook <i>template</i> that you can download
<a class="reference external" href="https://github.com/ORMIRcommunity/templates/blob/main/ORMIR_nb_template.ipynb">here</a>.
Just like when you write a paper, you fill out a journal template with your content, you can fill out the ORMIR community notebook template with your narrative and code.
<br>
<br>
<i>Why should I use the template?</i> We usually use notebooks to create use-cases for our Python packages.
Using the template allows us to harmonize our use-cases and to make sure we remember to include authors, licenses, references, etc.
</div>
</div>
<br>
<h4>GitHub</h4>
<!-- How do I structure the readme file of a GitHub repository? ----------------------------------->
<div class="accordion-container">
<button class="accordion" id="readme-structure">
How do I structure the readme file of a GitHub repository?
</button>
<div class="answer">
We created a GitHub readme <i>template</i> that you can download
<a class="reference external" href="https://github.com/ORMIRcommunity/templates/blob/main/ORMIR_readme_template.md">here</a>.
A readme file template allows us to harmonize our repositories and make sure we remember to include all sections, such as authors, licenses, use-cases, references, etc.
</div>
</div>
<br>
<!-- Trick to jump at the top of the title (not bottom) for internal links -->
<span class="anchor" id="data"></span>
<h4>Data</h4>
<!-- What image file formats should I use? ----------------------------------->
<div class="accordion-container">
<button class="accordion" id="ormir-mids">
What image file formats and folder structure should I use?
</button>
<div class="answer">
Our pipelines usually start with <code-text>.dcm</code-text> images for CT/MR acquisitions or <code-text>.isq</code-text> images for µCT/HR-pQCT acquisitions.
We recommend to organize image files and folders following the <a href="https://ormir-mids.github.io/specs">ORMIR-MIDS specifications</a> implemented by the <a href="https://github.com/ormir-mids/ormir-mids">ORMIR-MIDS Python package</a>.
</div>
</div>
<br>
<!-- Trick to jump at the top of the title (not bottom) for internal links -->
<span class="anchor" id="publications"></span>
<h4>Publishing</h4>
<!-- In what journal can I publish my Python package? ----------------------------------->
<div class="accordion-container">
<button class="accordion" id="journal">
In what journal can I publish my Python package?
</button>
<div class="answer">
Consider publishing in the <a class="reference external" href="https://joss.theoj.org/">Journal of Open Source Software (JOSS)</a>.
The paper is only a few pages and reviewers check your repository, helping you improve it.
</div>
</div>
<!-- How do I get a DOI for my code? ----------------------------------->
<div class="accordion-container">
<button class="accordion" id="code-doi">
How do I get a DOI for my code?
</button>
<div class="answer">
To get a permanent Digital Object Identifier (DOI) for your code so that it can be referenced, you can link your GitHub repository to Zenodo. You can find instructions on
<a class="reference external" href="https://docs.github.com/en/repositories/archiving-a-github-repository/referencing-and-citing-content">this webpage </a>
or in
<a class="reference external" href="https://www.youtube.com/watch?v=gp3D4mf6MHQ">this video</a>.
</div>
</div>
</div>
</div>
<br>
<center>
<strong>Do you have some questions that we didn't address? <a href="mailto:[email protected]">Contact us!</a> </strong>
</center>
</div>
</section>
<!-- ======= accordion-end ======= -->
<!-- ======= Footer ======= -->
<footer id="footer">
<div class="container d-md-flex py-4">
<div class="me-md-auto text-center text-md-start"></div>
<div class="social-links text-center text-md-right pt-3 pt-md-0">
<a href="https://github.com/ORMIRcommunity" class="github"><i class="bx bxl-github"></i></a>
<a href="https://www.linkedin.com/in/ormir-community-63b824307/" class="linkedin"><i class="bx bxl-linkedin"></i></a>
<a href="https://twitter.com/ORMIR_Community" class="twitter"><i class="bx bxl-twitter"></i></a>
</div>
</div>
</footer><!-- End Footer -->
<a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
<!-- Vendor JS Files -->
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="assets/vendor/glightbox/js/glightbox.min.js"></script>
<script src="assets/vendor/isotope-layout/isotope.pkgd.min.js"></script>
<script src="assets/vendor/swiper/swiper-bundle.min.js"></script>
<script src="assets/vendor/php-email-form/validate.js"></script>
<!-- Template Main JS File -->
<script src="assets/js/main.js"></script>
<!-- JavaScript to toggle accordion -->
<script src="assets/js/accordion.js"></script>
</script>
</body>
</html>