No problem.
Just about all of those gears will be coming out. How many teeth is the gear immediately after the 24T (red) gear? That may be a good place to attach an encoder pulley. TPI of the leadscrew and the gear ratio of the Stepper to Leadscrew pulleys will be input during the setup of the software.
This is my setup, and may make the concept a little clearer, 1:1 ratio between Spindle and encoder, 3:1 ratio stepper motor to leadscrew and a 16TPI leadscrew. The stepper info, ratio and leadscrew TPI will be input into the software during setup:
View attachment 422323
View attachment 422324