# \[ANN\] qtc.jl

**URL:** https://discourse.julialang.org/t/ann-qtc-jl/90919
**Category:** Biology, Health, and Medicine
**Created:** [November 27, 2022, 9:52pm UTC](https://discourse.julialang.org/t/ann-qtc-jl/90919 "2022-11-27T21:52:00Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![AdamWysokinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adamwysokinski/32/206422_2.png) [@AdamWysokinski](https://discourse.julialang.org/u/AdamWysokinski)
#### Post date: [November 27, 2022, 9:52pm UTC](https://discourse.julialang.org/t/ann-qtc-jl/90919/1 "2022-11-27T21:52:00Z")

</div>

[qtc.jl](https://codeberg.org/AdamWysokinski/qtc.jl) is a small Julia script to calculate the length of corrected QT interval (QTc) using Bazett, Fridericia, Hodges Sagie formulas.

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [November 27, 2022, 10:12pm UTC](https://discourse.julialang.org/t/ann-qtc-jl/90919/2 "2022-11-27T22:12:37Z")

</div>

Thanks for sharing this. Could I suggest refactoring this into a function so that we can take advantage of compilation?

Also you may want to look into using [GitHub - JuliaCI/PkgTemplates.jl: Create new Julia packages, the easy way](https://github.com/JuliaCI/PkgTemplates.jl) to package this formally so that it is easier to reuse this as part of other projects.

It’s not particularly efficient use of Julia to run top-level scripts like this. Not only do we have not have a chance to compile much of the script since it’s not a function, but we also cannot cache the results any compilation since its not a module.

---

<div class="post-metadata">

### Author: ![AdamWysokinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adamwysokinski/32/206422_2.png) [@AdamWysokinski](https://discourse.julialang.org/u/AdamWysokinski)
#### Post date: [November 28, 2022, 8:19am UTC](https://discourse.julialang.org/t/ann-qtc-jl/90919/3 "2022-11-28T08:19:59Z")

</div>

Thanks for the suggestion, it’s done and available as `qtc()` function.

---

<div class="post-metadata">

### Author: ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)
#### Post date: [November 28, 2022, 10:02am UTC](https://discourse.julialang.org/t/ann-qtc-jl/90919/4 "2022-11-28T10:02:25Z")

</div>

Two things that strikes the eye while reading your code :

- You could use explicit parameter names instead of this vector `param`, and even set default values using e.g.

```julia
function f(x,y; z = 3,t=4)
    return x + y + z + t
end
f(1,2)
f(1,2,t=1)

```

Note the `;` separating args and kwargs.

For units, you might use [Home · Unitful.jl](https://painterqubits.github.io/Unitful.jl/stable/), which is perfect for this (inputing units and converting them). It might reduce largely the complexity of your units handling 🙂

The whole Default arguments + interpreting values + convertions is like 60 lines of code, while with what i propose it might be only 3 or 4 🙂

---

<div class="post-metadata">

### Author: ![AdamWysokinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adamwysokinski/32/206422_2.png) [@AdamWysokinski](https://discourse.julialang.org/u/AdamWysokinski)
#### Post date: [November 28, 2022, 11:50am UTC](https://discourse.julialang.org/t/ann-qtc-jl/90919/5 "2022-11-28T11:50:08Z")

</div>

Thanks, I’m aware of this. The reason is that the function gets input arguments from the terminal script via ARGS, which are parsed within the function, not outside so explicit parameters would not work.

---

<div class="post-metadata">

### Author: ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)
#### Post date: [November 28, 2022, 12:10pm UTC](https://discourse.julialang.org/t/ann-qtc-jl/90919/6 "2022-11-28T12:10:33Z")

</div>

You could juste use

```julia
f(params) = f(params...)
f(x,y,z) = ...

```

to handle the fact that params are comming all together from the comand line. Then, even from the comand line, params could be in `UnitFull.jl`’s format 🙂
