Django: Intro

I found some of the documentation for Django very confusing to me, the beginner.  The steps in retrospect are very straightforward.  In fact, a version of the tutorial is missing the instructions on establishing a virtualenv, so I had to embark on a voyage of discovery

pip install virtualenv


to make sure it’s installed or install if it isn’t.

The basic command

virtualenv venv

where venv is the name of your virtual environment.

Then either CD into the venv folder\Scripts or add the path and issue:


Your prompt will now change from a standard command prompt to:

(venv) C:\Python36\web\venv\Scripts>

Indicating that  your virtualenv “(venv)” is active.

Super-handy batch file to activate your venv and leave the prompt open to do work.

@echo off
cmd /k "cd /d C:\python36\venv\Scripts & activate & cd /d C:\python36\"

I dropped this nugget on the desktop with name venv.bat

The django documentation tutorial gets a little confusing now because of the doubled mysite/mysite site structure.



Pitfall:  If your code editor is not correctly configured for python and using the tab character instead of the python standard (4 spaces), your django files will throw this error.  Took a little while and a bit of frustration to figure that one out.  I’m using notepad++ and had to override the tab settings to put in 4 spaces.  

return self.pub_date >= - datetime.timedelta(days=1)
TabError: inconsistent use of tabs and spaces in indentation

To manipulate the DB through the API/Shell

python shell



PrimaryKey lookup is the most common QueryString (pk=x)


Create choices for the question QuerySet

q = Question.objects.get(pk=1)
q.choice_set.create(choice_text='Not much', votes=0)

More QuerySet Mojo

<QuerySet [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>,
<Choice: Just hacking again>]>
c = q.choice_set.create(choice_text='Just hacking again', votes=0)
c.delete()            #Drops it from the DB

More QuerySet Mojo

c = q.choice_set.create(choice_text='Just hacking again', votes=0)

More QuerySet Mojo

c = q.choice_set.create(choice_text='Just hacking again', votes=0)







Teleradiology Network Topology

Getting started with telerad has teething issues.  I’ve changed my network topology to see if I can maximize throughput.  The effects of the topology change are modest.  Images below:


Original topology with cable modem -> router -> gigabit switch -> workstation

Modified topology:  cable modem (moved as close to source as possible) -> router -> gigabit switch -> workstation

Modified topology:  cable modem (moved as close to source as possible) -> router -> workstation


Impression: No real speed change, modest drop in latency with elimination of 1 hop.


Impression: The local environment has little effect on speed of image transfer.  Upgrading the connection and modem however does have a large effect. No duh!





The 10 Pillars of Lung Cancer Screening

Teaching Points

  • The NLST was the first randomized controlled trial to report a significant reduction in disease-specific lung cancer mortality due to screening.
  • After a USPSTF grade B recommendation was issued in December 2013 and a positive coverage decision was granted by CMS in February 2015, millions of Americans at high risk became eligible for CT lung screening with no insurance co-payment.
  • In February 2015, CMS decided to cover annual LCS with low-dose CT for asymptomatic individuals aged 55–77 years with a high-risk tobacco smoking history. Specifically, reim  bursement covered those with a smoking history of at least 30 pack-years (1 pack-year equals smoking one pack per day for 1 year) who are currently smoking or who had quit less than 15 years ago.
  • Clear and concise communication of screening results is central to guiding providers toward the appropriate management pathway and to minimizing unnecessary workup.
  • Lung-RADS is a structured reporting system that defines what constitutes a positive screening test and links accepted nodule care pathways to the variety of nodules present on LCS images.
  • Source


  • The NLST was huge relative to prior investigations.  n = 53,454 whereas the largest prior was an order of magnitude smaller.
  • Perifissural location (meaning likely a subpleural node which is very common) is not part of the criteria.
  • Measurements are average of the longest axis and shortest axis on axial imaging.


  • In the findings section, the following descriptors should be provided for each nodule:
    • location (lobe, segment, with series or image number);
    • size, determined on lung window images and reported as the average diameter rounded to the nearest whole number;
    • attenuation (soft tissue, type of calcification, fat); morphology (solid, nonsolid and part solid [containing both solid and nonsolid components]);
    • margins (smooth, lobulated, spiculated).
  • Any interval change should be addressed in comparison with the findings from previous examinations, with particular attention to those from the baseline study.
  •  Lung-RADS defines growth as a greater than 1.5-mm increase in size to account for known interreader variability.


  • Category 0: Incomplete Data.
  • Category 1: No Nodule of benign nodules (calcified or fat containing).
    • Probability of malignancy < 1%.
    • Recommend follow-up low-dose CT in 12 months.
  • Category 2:  Benign appearance or behavior.  Solid Nodule up to 6 mm and non-solid nodule up to 20 mm.
    • Probability of malignancy < 1%.
    • Recommend follow-up low-dose CT in 12 months.
    • Notably: recommendations same as above
  • Category 3: Probably benign.
    • >= 6 to
    • 1%–2% probability that it will become clinically active cancer.
    • Recommend followup low-dose CT in 6 months.
      • Some category 3 nodules trigger direct physician-to-physician communication.
  • Category 4A: Suspicious for Malignancy.  All endobronchial Nodules.
    • Management includes additional diagnostic testing with low-dose CT in 3 months, contrast material–enhanced CT, PET/CT, and/or tissue sampling.
      • Category 4 and some category 3 nodules trigger direct physician-to-physician communication.
  • Category 4B: Suspicious for Malignancy.

Flow Chart: Solid


Flow Chart: Part-Solid


Flow Chart: Non-Solid


Synthesis Table

(PDF Linkage because of mice type on this image!)

LungRADS v 1.0 04 28 14.xlsx

Example Report Template


Cervical and Lumbar Epidural Injections


Executive Summary

  • General indications for ESI include herniated disk disease with or without radicular pain, spinal stenosis, axial low back pain, and post–lumbar surgery syndrome.
  • With an interlaminar ESI, a single line and a well-defined or smudged convexity along the spinolaminar line on the lateral view suggest that the needle tip is positioned correctly in the epidural space. On the AP view, contrast agent dispersion with drug injection may outline exiting spinal nerves.
  • With a transforaminal ESI, if the needle tip is in the true epidural space, a test dose of contrast agent will flow upward (occasionally downward) along the medial margin of the pedicles and along the exiting nerve.
  • With an intradural injection, contrast material rapidly disperses and accumulates at the ventral portion of the spinal canal, forming a cerebrospinal fluid–contrast agent level (dorsal cerebrospinal fluid and ventral contrast material) because of the patient’s prone position. The AP view demonstrates a symmetric distribution of contrast material, similar to that seen at myelography.
  • At imaging, intraepineural injection manifests as two thin lines resembling a so-called tram track, with a subtle feathery appearance inside the nerve root and sharp outlines.
  • Source

Very Useful tabular Data

Resetting Cost Basis

There are a lot of ways to get your taxable income down: 529, defined benefit plans, the usual suspects of IRA and 401(k).  This strategy is to reset the basis on appreciated assets by buying and selling.  The real term is “realizing capital gains”.

This strategy will only work if you’re in the 0% long-term capital gains bracket. The limits are high, but not terribly unreasonable for people with an asset cushion.  2017-tax-brackets

As the table above shows, a couple would need to have under $75,900 in AGI for the year in order to execute this strategy.  Not easy for a working physician but possible with a tax-deferred sledgehammer.

Perhaps it’s a year with a lot of vacation or illness.  Perhaps a prolonged recuperation from an operation.  Or maybe you’re just backing away from drinking from the fire hose of practice to refresh and adjust priorities.  Regardless of the reason, it merits consideration.

Simply sell your assets, and buy them back immediately.  There is no wash sale rule for realizing capital gains.  This will reset your cost basis moving forward.

Caveat Emptor

You will pay state tax on these realized gains since those are not governed by the IRS.  This could be an incredible opportunity if you were to transit to a state with no income tax for a year.

The Ideal Scenario

You’re burned out at work, want a change of scenery and lifestyle temporarily, and want to live off your assets for a bit.  Perhaps do some locums to cover the bills but take the time enjoy a life outside of work.  I’m not a fan of the saying “you’ve earned it”, but perhaps you need it.  This maneuver will make it work to your financial advantage.


From the IRS:

Earnings are not subject to federal tax and generally not subject to state tax when used for the qualified education expenses of the designated beneficiary, such as tuition, fees, books, as well as room and board. Contributions to a 529 plan, however, are not deductible.

Some off-the-beaten-path 529 uses:

Study Abroad

The bulk of the expense of studying abroad is eligible for 529 use if the program qualifies.  This specifically does not include airfare or healthcare but DOES include tuition, fees and room and board.  I had never considered this as an option, but considering the huge tax advantage of a 529 plan, this merits consideration, particularly if you have children that don’t need it or don’t have children.

Personally, I’d consider this for postgraduate training if permissible or for a language study course.  It’d be an extended tax-free vacation.